TFGENZOO.flows.squeeze module

class TFGENZOO.flows.squeeze.Squeeze(with_zaux=False)[source]

Bases: TFGENZOO.flows.flowbase.FlowBase

Squeeze Layer

Sources:

Note

  • forward formula
    z = reshape(x, [B, H // 2, W // 2, C * 4])
  • inverse formula
    x = reshape(z, [B, H, W, C])
  • checkerboard spacing

    e.g.

    [[[[1], [2], [5], [6]],
    [[3], [4], [7], [8]],
    [[9], [10], [13], [14]],
    [[11], [12], [15], [16]]]]

    to

    [[[ 1, 5],
    [ 9, 13]]]
    [[[ 2, 6],
    [10, 14]]]
    [[[ 3, 7],
    [11, 15]]]
    [[[ 4, 8],
    [12, 16]]]
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, **kwargs)[source]
class TFGENZOO.flows.squeeze.Squeeze2DWithMask(with_zaux: bool = False, n_squeeze: int = 2)[source]

Bases: TFGENZOO.flows.flowbase.FlowBase

build(input_shape)[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).

forward(x: tensorflow.python.framework.ops.Tensor, zaux: tensorflow.python.framework.ops.Tensor = None, mask: tensorflow.python.framework.ops.Tensor = None, **kwargs)[source]
Parameters
  • x (tf.Tensor) – input tensor [B, T, C]

  • zaux (tf.Tensor) – pre-latent tensor [B, T, C’’]

  • mask (tf.Tensor) – mask tensor [B, T, M] where M may be 1

Returns

reshaped input tensor [B, T // n_squeeze, C * 2] tf.Tensor: reshaped pre-latent tensor [B, T // n_squeeze, C’’ * n_squeeze] tf.Tensor: reshaped mask tensor [B, T // 2]

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.

inverse(z: tensorflow.python.framework.ops.Tensor, zaux: tensorflow.python.framework.ops.Tensor = None, mask: tensorflow.python.framework.ops.Tensor = None, **kwargs)[source]
Parameters
  • z (tf.Tensor) – input tensor [B, T // n_squeeze, C * n_squeeze]

  • zaux (tf.Tensor) – pre-latent tensor [B, T // n_squeeze, C’’ * n_squeeze]

  • mask (tf.Tensor) – pre-latent tensor [B, T // n_squeeze, 1]

Returns

reshaped input tensor [B, T, C] tf.Tensor: reshaped pre-latent tensor [B, T, C’’] tf.Tensor: mask tensor [B, T, 1]

Return type

tf.Tensor