theanets.recurrent.Autoencoder

class theanets.recurrent.Autoencoder(layers, loss='mse', weighted=False)

An autoencoder network attempts to reproduce its input.

Notes

Autoencoder models default to a MSE loss. To use a different loss, provide a non-default argument for the loss keyword argument when constructing your model.

Examples

To create a recurrent autoencoder, just create a new model instance. Often you’ll provide the layer configuration at this time:

>>> model = theanets.recurrent.Autoencoder([10, (20, 'rnn'), 10])

See Creating a Model for more information.

Data

Training data for a recurrent autoencoder takes the form of a three-dimensional array. The shape of this array is (num-examples, num-time-steps, num-variables): the first axis enumerates data points in a batch, the second enumerates time steps, and the third enumerates the variables in the model.

For instance, to create a training dataset containing 1000 examples, each with 100 time steps:

>>> inputs = np.random.randn(1000, 100, 10).astype('f')

Training

Training the model can be as simple as calling the train() method:

>>> model.train([inputs])

See Training a Model for more information.

Use

A model can be used to predict() the output of some input data points:

>>> test = np.random.randn(3, 200, 10).astype('f')
>>> print(model.predict(test))

Note that the test data does not need to have the same number of time steps as the training data.

Additionally, autoencoders can encode() a set of input data points:

>>> enc = model.encode(test)

See Using a Model for more information.

__init__(layers, loss='mse', weighted=False)

Methods

Attributes

DEFAULT_OUTPUT_ACTIVATION
INPUT_NDIM
inputs A list of Theano variables for feedforward computations.
num_params Number of parameters in the entire network model.
params A list of the learnable Theano parameters for this network.
variables A list of Theano variables for loss computations.