neupy.layers.Deconvolution

class neupy.layers.Deconvolution[source]

Deconvolution layer (also known as Transposed Convolution.).

Parameters:
size : tuple of int

Filter shape. In should be defined as a tuple with three integers (filter rows, filter columns, output channels).

padding : {same, valid}, int, tuple

Zero padding for the input tensor.

  • valid - Padding won’t be added to the tensor. Result will be the same as for padding=0
  • same - Padding will depend on the number of rows and columns in the filter. This padding makes sure that image with the stride=1 won’t change its width and height. It’s the same as padding=(filter rows // 2, filter columns // 2).
  • Custom value for the padding can be specified as an integer, like padding=1 or it can be specified as a tuple when different dimensions have different padding values, for example padding=(2, 3).

Defaults to valid.

stride : tuple with ints, int.

Stride size. Defaults to (1, 1)

dilation : int, tuple

Rate for the filter upsampling. When dilation > 1 layer will become dilated convolution (or atrous convolution). Defaults to 1.

weight : array-like, Tensorfow variable, scalar or Initializer

Defines layer’s weights. Shape of the weight will be equal to (filter rows, filter columns, output channels, input channels). Default initialization methods you can find here. Defaults to HeNormal(gain=2).

bias : 1D array-like, Tensorfow variable, scalar, Initializer or None

Defines layer’s bias. Default initialization methods you can find here. Defaults to Constant(0). The None value excludes bias from the calculations and do not add it into parameters list.

name : str or None

Layer’s name. Can be used as a reference to specific layer. Name Can be specified as:

  • String: Specified name will be used as a direct reference to the layer. For example, name=”fc”
  • Format string: Name pattern could be defined as a format string and specified field will be replaced with an index. For example, name=”fc{}” will be replaced with fc1, fc2 and so on. A bit more complex formatting methods are acceptable, for example, name=”fc-{:<03d}” will be converted to fc-001, fc-002, fc-003 and so on.
  • None: When value specified as None than name will be generated from the class name.

Defaults to None.

Examples

>>> from neupy.layers import *
>>> network = join(
...     Input((28, 28, 3)),
...     Convolution((3, 3, 16)),
...     Deconvolution((3, 3, 1)),
... )
>>> network
(?, 28, 28, 3) -> [... 3 layers ...] -> (?, 28, 28, 1)
Attributes:
variables : dict

Variable names and their values. Dictionary can be empty in case if variables hasn’t been created yet.

Methods

variable(value, name, shape=None, trainable=True) Initializes variable with specified values.
get_output_shape(input_shape) Computes expected output shape from the layer based on the specified input shape.
output(*inputs, **kwargs) Propagates input through the layer. The kwargs variable might contain additional information that propagates through the network.
create_variables(input_shape)[source]
options = {'bias': Option(class_name='Convolution', value=ParameterProperty(name="bias")), 'dilation': Option(class_name='Convolution', value=Spatial2DProperty(name="dilation")), 'name': Option(class_name='BaseLayer', value=Property(name="name")), 'padding': Option(class_name='Convolution', value=PaddingProperty(name="padding")), 'size': Option(class_name='Convolution', value=TypedListProperty(name="size")), 'stride': Option(class_name='Convolution', value=Spatial2DProperty(name="stride")), 'weight': Option(class_name='Convolution', value=ParameterProperty(name="weight"))}[source]
output(input, **kwargs)[source]
output_shape_per_dim(*args, **kwargs)[source]