neupy.layers.reshape module

class neupy.layers.reshape.Reshape[source]

Layer reshapes input tensor.

Parameters:
shape : tuple

New feature shape. If one dimension specified with the -1 value that this dimension will be computed from the total size that remains. Defaults to -1.

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

Covert 4D input to 2D

>>> from neupy.layers import *
>>> network = Input((2, 5, 5)) >> Reshape()
(?, 2, 5, 5) -> [... 2 layers ...] -> (?, 50)

Convert 3D to 4D

>>> from neupy.layers import *
>>> network = Input((5, 4)) >> Reshape((5, 2, 2))
(?, 5, 4) -> [... 2 layers ...] -> (?, 5, 2, 2)
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.
get_output_shape(input_shape)[source]
options = {'name': Option(class_name='BaseLayer', value=Property(name="name")), 'shape': Option(class_name='Reshape', value=TypedListProperty(name="shape"))}[source]
output(input, **kwargs)[source]

Reshape the feature space for the input value.

Parameters:
input : array-like or Tensorfow variable
shape = None[source]
class neupy.layers.reshape.Transpose[source]

Layer transposes input tensor. Permutes the dimensions according to the perm parameter.

Parameters:
perm : tuple or list

A permutation of the dimensions of the input tensor.

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 = Input((7, 11)) >> Transpose((0, 2, 1))
(?, 7, 11) -> [... 2 layers ...] -> (?, 11, 7)
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.
fail_if_shape_invalid(input_shape)[source]
get_output_shape(input_shape)[source]
options = {'name': Option(class_name='BaseLayer', value=Property(name="name")), 'perm': Option(class_name='Transpose', value=TypedListProperty(name="perm"))}[source]
output(input, **kwargs)[source]
perm = None[source]