class neupy.layers.Deconvolution[source]

Deconvolution layer. It’s commonly called like this in the literature, but it’s just gradient of the convolution and not actual deconvolution.

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)

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 identifier. If name is equal to None than name will be generated automatically. Defaults to None.


>>> from neupy import layers
>>> layers.join(
...     layers.Input((28, 28, 3)),
...     layers.Convolution((3, 3, 16)),
...     layers.Deconvolution((3, 3, 1)),
... )
input_shape : tuple

Returns layer’s input shape in the form of a tuple. Shape will not include batch size dimension.

output_shape : tuple

Returns layer’s output shape in the form of a tuple. Shape will not include batch size dimension.

training_state : bool

Defines whether layer in training state or not. Training state will enable some operations inside of the layers that won’t work otherwise.

parameters : dict

Parameters that networks uses during propagation. It might include trainable and non-trainable parameters.

graph : LayerGraph instance

Graphs that stores all relations between layers.


disable_training_state() Context manager that switches off trainig state.
initialize() Set up important configurations related to the layer.
dilation = None[source]
options = {'bias': Option(class_name='ParameterBasedLayer', value=ParameterProperty(name="bias")), '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]

Return output base on the input value.

output_shape_per_dim(*args, **kwargs)[source]