TFGENZOO.layers.flowtts_coupling module¶
-
TFGENZOO.layers.flowtts_coupling.
CouplingBlock
(x: tensorflow.python.framework.ops.Tensor, cond: tensorflow.python.framework.ops.Tensor, depth, **kwargs)[source]¶ - Parameters
x (tf.Tensor) – input contents tensor [B, T, C]
c (tf.Tensor) – input conditional tensor [B, T, C’] where C’ can be different with C
- Returns
- CouplingBlock
reference: Flow-TTS
- Return type
tf.keras.Model
Examples
>>> import tensorflow as tf >>> from utils.coupling_block import CouplingBlock >>> x = tf.keras.layers.Input([None, 32]) >>> c = tf.keras.layers.Input([None, 128]) >>> cp = CouplingBlock(x, c, depth=256) >>> cp.summary() Model: "model" __________________________________________________________________________________________________ Layer (type) Output Shape Param # Connected to ================================================================================================== input_1 (InputLayer) [(None, None, 32)] 0 __________________________________________________________________________________________________ conv1d (Conv1D) (None, None, 256) 8192 input_1[0][0] __________________________________________________________________________________________________ input_2 (InputLayer) [(None, None, 128)] 0 __________________________________________________________________________________________________ gtu (GTU) (None, None, 256) 98816 conv1d[0][0] __________________________________________________________________________________________________ tf_op_layer_AddV2 (TensorFlowOp [(None, None, 256)] 0 gtu[0][0] conv1d[0][0] __________________________________________________________________________________________________ conv1d_1 (Conv1D) (None, None, 64) 16448 tf_op_layer_AddV2[0][0] ================================================================================================== Total params: 123,456 Trainable params: 123,456 Non-trainable params: 0 __________________________________________________________________________________________________ >>> cp([x, c]) <tf.Tensor 'model_1/Identity:0' shape=(None, None, 64) dtype=float32>
-
class
TFGENZOO.layers.flowtts_coupling.
GTU
(**kwargs)[source]¶ Bases:
tensorflow.python.keras.engine.base_layer.Layer
GTU layer proposed in Flow-TTS
Note
- formula
- \[z = tanh(W_{f, k} \star y) \odot sigmoid(W_{g, k} \star c)\]
-
build
(input_shape: tensorflow.python.framework.tensor_shape.TensorShape)[source]¶ Creates the variables of the layer (optional, for subclass implementers).
This is a method that implementers of subclasses of Layer or Model can override if they need a state-creation step in-between layer instantiation and layer call.
This is typically used to create the weights of Layer subclasses.
- Parameters
input_shape – Instance of TensorShape, or list of instances of TensorShape if the layer expects a list of inputs (one instance per input).
-
call
(y: tensorflow.python.framework.ops.Tensor, c: tensorflow.python.framework.ops.Tensor, **kwargs)[source]¶ - Parameters
y (tf.Tensor) – input contents tensor [B, T, C]
c (tf.Tensor) – input conditional tensor [B, T, C’] where C’ can be different with C
- Returns
[B, T, C]
- Return type
tf.Tensor
-
get_config
()[source]¶ Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.
The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).
- Returns
Python dictionary.