TFGENZOO.flows.factor_out module

class TFGENZOO.flows.factor_out.FactorOut(with_zaux: bool = False, conditional: bool = False, dims: int = 4)[source]

Bases: TFGENZOO.flows.flowbase.FactorOutBase

Basic Factor Out Layer

This layer drops factor-outed Tensor z_i

Note

  • forward procedure
    input : h_{i-1}
    output : h_{i}, loss

    [z_i, h_i] = split(h_{i-1})

    loss =
    z_i sim N(0, 1) if conditional is False
    z_i sim N(mu, sigma) if conditional is True
    ,where
    mu, sigma = Conv(h)
  • inverse procedure
    input : h_{i}
    output : h_{i-1}

    sample z_i from N(0, 1) or N(mu, sigma) by conditional
    h_{i-1} = [z_i, h_i]
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).

calc_ll(z1: tensorflow.python.framework.ops.Tensor, z2: tensorflow.python.framework.ops.Tensor)[source]
forward(x: tensorflow.python.framework.ops.Tensor, zaux: tensorflow.python.framework.ops.Tensor = None, **kwargs)[source]
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.

inverse(z: tensorflow.python.framework.ops.Tensor, zaux: tensorflow.python.framework.ops.Tensor = None, temparature: float = 0.2, **kwargs)[source]
split2d_prior(z: tensorflow.python.framework.ops.Tensor)[source]
class TFGENZOO.flows.factor_out.FactorOut2DWithMask(with_zaux: bool = False, conditional: bool = False, **kwargs)[source]

Bases: TFGENZOO.flows.factor_out.FactorOutWithMask

calc_ll(z1: tensorflow.python.framework.ops.Tensor, z2: tensorflow.python.framework.ops.Tensor, mask_tensor: tensorflow.python.framework.ops.Tensor = None)[source]

Calculate log likelihood. :param z1: [B, T, C // 2] :type z1: tf.Tensor :param z2: [B, T, C // 2] :type z2: tf.Tensor

forward(x: tensorflow.python.framework.ops.Tensor, zaux: tensorflow.python.framework.ops.Tensor = None, mask=None, **kwargs)[source]
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.

inverse(z: tensorflow.python.framework.ops.Tensor, zaux: tensorflow.python.framework.ops.Tensor = None, mask=None, temparature: float = 0.2, **kwargs)[source]
split2d_prior(z: tensorflow.python.framework.ops.Tensor)[source]
class TFGENZOO.flows.factor_out.FactorOutWithMask(with_zaux: bool = False, conditional: bool = False, dims: int = 4)[source]

Bases: TFGENZOO.flows.factor_out.FactorOut

Basic Factor Out Layer With Mask

This layer drops factor-outed Tensor z_i

Note

  • forward procedure
    input : h_{i-1}
    output : h_{i}, loss

    [z_i, h_i] = split(h_{i-1})

    loss =
    z_i sim N(0, 1) if conditional is False
    z_i sim N(mu, sigma) if conditional is True
    ,where
    mu, sigma = Conv(h)
  • inverse procedure
    input : h_{i}
    output : h_{i-1}

    sample z_i from N(0, 1) or N(mu, sigma) by conditional
    h_{i-1} = [z_i, h_i]
  • mask notes
    mask shape is [B, T, M] where M may be 1
    reference glow-tts
calc_ll(z1: tensorflow.python.framework.ops.Tensor, z2: tensorflow.python.framework.ops.Tensor, mask_tensor: tensorflow.python.framework.ops.Tensor = None)[source]
Parameters
  • z1 (tf.Tensor) – [B, T, C // 2]

  • z2 (tf.Tensor) – [B, T, C // 2]

forward(x: tensorflow.python.framework.ops.Tensor, zaux: tensorflow.python.framework.ops.Tensor = None, mask=None, **kwargs)[source]
inverse(z: tensorflow.python.framework.ops.Tensor, zaux: tensorflow.python.framework.ops.Tensor = None, mask=None, temparature: float = 0.2, **kwargs)[source]
TFGENZOO.flows.factor_out.main()[source]