neupy.layers.reshape module

class neupy.layers.reshape.Reshape[source]

Reshapes input tensor.

Parameters:

shape : tuple or list

New feature shape. The -1 value means that this value will be computed from the total size that remains. If you need to get the output feature with more that 2 dimensions then you can set up new feature shape using tuples or list. Defaults to [-1].

name : str or None

Layer’s identifier. If name is equal to None than name will be generated automatically. Defaults to None.

Examples

Covert 4D input to 2D

>>> from neupy.layers import *
>>> conn = Input((2, 5, 5)) > Reshape()
>>> conn.input_shape
(2, 5, 5)
>>> conn.output_shape
(50,)

Convert 3D to 4D

>>> from neupy.layers import *
>>> conn = Input((5, 4)) > Reshape((5, 2, 2))
>>> conn.input_shape
(5, 4)
>>> conn.output_shape
(5, 2, 2)

Attributes

input_shape (tuple) Layer’s input shape.
output_shape (tuple) Layer’s output shape.
training_state (bool) Defines whether layer in training state or not.
parameters (dict) Trainable parameters.
graph (LayerGraph instance) Graphs that stores all relations between layers.

Methods

disable_training_state() Swith off trainig state.
initialize() Set up important configurations related to the layer.
options = {'name': Option(class_name='BaseLayer', value=Property(name="name")), 'shape': Option(class_name='Reshape', value=NewShapeProperty(name="shape"))}[source]
output(input_value)[source]

Reshape the feature space for the input value.

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

Transposes input. Permutes the dimensions according to perm.

Parameters:

perm : tuple or list

A permutation of the dimensions of the input tensor. Layer cannot transpose batch dimension and using 0 in the list of permuted dimensions is not allowed.

name : str or None

Layer’s identifier. If name is equal to None than name will be generated automatically. Defaults to None.

Examples

>>> from neupy.layers import *
>>> conn = Input((7, 11)) > Transpose((2, 1))
>>> conn.input_shape
(7, 11)
>>> conn.output_shape
(11, 7)

Attributes

input_shape (tuple) Layer’s input shape.
output_shape (tuple) Layer’s output shape.
training_state (bool) Defines whether layer in training state or not.
parameters (dict) Trainable parameters.
graph (LayerGraph instance) Graphs that stores all relations between layers.

Methods

disable_training_state() Swith off trainig state.
initialize() Set up important configurations related to the layer.
options = {'name': Option(class_name='BaseLayer', value=Property(name="name")), 'perm': Option(class_name='Transpose', value=TypedListProperty(name="perm"))}[source]
output(input_value)[source]

Return output base on the input value.

Parameters:input_value
output_shape[source]
perm = None[source]
validate(input_shape)[source]

Validate input shape value before assigning it.

Parameters:input_shape : tuple with int