pixelcnn_2d_input

tfsnippet.layers.pixelcnn_2d_input(*args, **kwargs)

Prepare the input for a PixelCNN 2D network (Tim Salimans, 2017).

This method must be applied on the input once before any other PixelCNN 2D layers, for example:

input = ...  # the input x

# prepare for the convolution stack
output = spt.layers.pixelcnn_2d_input(input)

# apply the PixelCNN 2D layers.
for i in range(5):
    output = spt.layers.pixelcnn_conv2d_resnet(
        output,
        out_channels=64,
        vertical_kernel_size=(2, 3),
        horizontal_kernel_size=(2, 2),
        activation_fn=tf.nn.leaky_relu,
        normalizer_fn=spt.layers.batch_norm
    )

# get the final output of the PixelCNN 2D network.
output = pixelcnn_2d_output(output)
Parameters:
  • input (Tensor) – The input tensor, at least 4-d.
  • channels_last (bool) – Whether or not the channel axis is the last axis in input? (i.e., the data format is “NHWC”)
  • auxiliary_channel (bool) – Whether or not to add a channel to input, with all elements set to 1?
  • name (str) – Default name of the name scope. If not specified, generate one according to the method name.
Returns:

The PixelCNN layer output.

Return type:

PixelCNN2DOutput