Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
TensorSpeech
GitHub Repository: TensorSpeech/TensorFlowTTS
Path: blob/master/tensorflow_tts/models/base_model.py
1558 views
1
# -*- coding: utf-8 -*-
2
# Copyright 2020 TensorFlowTTS Team.
3
#
4
# Licensed under the Apache License, Version 2.0 (the "License");
5
# you may not use this file except in compliance with the License.
6
# You may obtain a copy of the License at
7
#
8
# http://www.apache.org/licenses/LICENSE-2.0
9
#
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
15
"""Base Model for all model."""
16
17
import tensorflow as tf
18
import yaml
19
import os
20
import numpy as np
21
22
from tensorflow_tts.utils.utils import MODEL_FILE_NAME, CONFIG_FILE_NAME
23
24
25
class BaseModel(tf.keras.Model):
26
def set_config(self, config):
27
self.config = config
28
29
def save_pretrained(self, saved_path):
30
"""Save config and weights to file"""
31
os.makedirs(saved_path, exist_ok=True)
32
self.config.save_pretrained(saved_path)
33
self.save_weights(os.path.join(saved_path, MODEL_FILE_NAME))
34
35