theanets.layers.feedforward.Tied

class theanets.layers.feedforward.Tied(partner, **kwargs)[source]

A tied-weights feedforward layer shadows weights from another layer.

Parameters:
partner : str or theanets.layers.base.Layer

The “partner” layer to which this layer is tied.

Notes

Tied weights are typically featured in some types of autoencoder models (e.g., PCA). A layer with tied weights requires a “partner” layer – the tied layer borrows the weights from its partner and uses the transpose of them to perform its feedforward mapping. Thus, tied layers do not have their own weights. On the other hand, tied layers do have their own bias values, but these can be fixed to zero during learning to simulate networks with no bias (e.g., PCA on mean-centered data).

Parameters

  • b — bias

Outputs

  • out — the post-activation state of the layer
  • pre — the pre-activation state of the layer
Attributes:
partner : theanets.layers.base.Layer

The “partner” layer to which this layer is tied.

__init__(partner, **kwargs)[source]

x.__init__(…) initializes x; see help(type(x)) for signature

Methods

__init__(partner, **kwargs) x.__init__(…) initializes x; see help(type(x)) for signature
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.
bind(graph[, reset, initialize]) Bind this layer into a computation graph.
connect(inputs) Create Theano variables representing the outputs of this layer.
find(key) Get a shared variable for a parameter by name.
full_name(name) Return a fully-scoped name for the given layer output.
log() Log some information about this layer.
log_params() Log information about this layer’s parameters.
resolve_inputs(layers) Resolve the names of inputs for this layer into shape tuples.
resolve_outputs() Resolve the names of outputs for this layer into shape tuples.
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_name Name of layer input (for layers with one input).
input_shape Shape of layer input (for layers with one input).
input_size Size of layer input (for layers with one input).
output_name Full name of the default output for this layer.
output_shape Shape of default output from this layer.
output_size Number of “neurons” in this layer’s default output.
params A list of all parameters in this layer.
log()[source]

Log some information about this layer.

resolve_inputs(layers)[source]

Resolve the names of inputs for this layer into shape tuples.

Parameters:
layers : list of Layer

A list of the layers that are available for resolving inputs.

Raises:
theanets.util.ConfigurationError :

If an input cannot be resolved.

resolve_outputs()[source]

Resolve the names of outputs for this layer into shape tuples.

setup()[source]

Set up the parameters and initial values for this layer.

to_spec()[source]

Create a specification dictionary for this layer.

Returns:
spec : dict

A dictionary specifying the configuration of this layer.

transform(inputs)[source]

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:
output : Theano expression

The output for this layer is the same as the input.

updates : list

An empty updates list.