theanets.recurrent.Regressor

class theanets.recurrent.Regressor(layers=(), loss='mse', weighted=False, rng=13)

A regressor attempts to produce a target output given some inputs.

Notes

Regressor 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 regression model, just create a new class instance. Often you’ll provide the layer configuration at this time:

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

See Creating a Model for more information.

Data

Training data for a recurrent regression model takes the form of two three-dimensional arrays. The shapes of these arrays are (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 (input variables for the input array, and output variables for the output array) 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')
>>> outputs = np.random.randn(1000, 100, 3).astype('f')

Training

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

>>> model.train([inputs, outputs])

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.

See Using a Model for more information.

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

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.