theanets.layers.base.Reshape

class theanets.layers.base.Reshape(shape, **kwargs)

Reshape an input to have different numbers of dimensions.

Parameters:

shape : sequence of int

The desired shape of the output “vectors” for this layer. This should not include the leading axis of the actual shape of the data arrays processed by the graph! For example, to reshape input vectors of length a * b into 2D output “images” use (a, b) as the shape—not (batch-size, a, b).

Notes

In theanets, the leading axis of a data array always runs over the examples in a mini-batch. Since the number of examples in a mini-batch is constant throughout a network graph, this layer always preserves the shape of the leading axis of its inputs.

If you want to vectorize a data array, you could do that using (-1, ) as the shape for this layer. But it’s often easier to read if you use the Flatten layer type to reshape a layer’s output into a flat vector.

Outputs

  • out — reshaped inputs

Attributes

shape (list of int) The desired shape of the output “vectors” for this layer.
__init__(shape, **kwargs)

Methods

__init__(shape, **kwargs)
add_bias(name, size[, mean, std]) Helper method to create a new bias vector.
add_weights(name, nin, nout[, mean, std, ...]) Helper method to create a new weight matrix.
connect(inputs) Create Theano variables representing the outputs of this layer.
find(key) Get a shared variable for a parameter by name.
log() Log some information about this layer.
output_name([name]) Return a fully-scoped name for the given layer output.
setup() Set up the parameters and initial values for this layer.
to_spec() Create a specification dictionary for this layer.
transform(inputs) Transform the inputs for this layer into an output for the layer.

Attributes

input_size For networks with one input, get the input size.
num_params Total number of learnable parameters in this layer.
params A list of all parameters in this layer.
to_spec()

Create a specification dictionary for this layer.

Returns:

spec : dict

A dictionary specifying the configuration of this layer.

transform(inputs)

Transform the inputs for this layer into an output for the layer.

Parameters:

inputs : dict of Theano expressions

Symbolic inputs to this layer, given as a dictionary mapping string names to Theano expressions. See Layer.connect().

Returns:

outputs : dict of Theano expressions

A map from string output names to Theano expressions for the outputs from this layer. This layer type generates a “pre” output that gives the unit activity before applying the layer’s activation function, and an “out” output that gives the post-activation output.

updates : list of update pairs

An empty sequence of updates.