theanets.feedforward.Regressor¶
-
class
theanets.feedforward.
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 theloss
keyword argument when constructing your model.Examples
To create a regression model, just create a new class instance. Often you’ll provide the layer configuration at this time:
>>> model = theanets.Regressor([10, 20, 3])
See Creating a Model for more information.
Data
Training data for a regression model takes the form of two two-dimensional arrays. The shapes of both of these arrays are (num-examples, num-variables) – the first axis enumerates data points in a batch, and the second enumerates the relevant variables (input variables for the input array, and output variables for the output array).
For instance, to create a training dataset containing 1000 examples:
>>> inputs = np.random.randn(1000, 10).astype('f') >>> outputs = np.random.randn(1000, 3).astype('f')
Training
Training the model can be as simple as calling the
train()
method, with the inputs and target outputs as data:>>> model.train([inputs, outputs])
See Training a Model for more information.
Use
A regression model can be used to
predict()
the output of some input data points:>>> test = np.random.randn(3, 10).astype('f') >>> print(model.predict(test))
See Using a Model for more information.
-
__init__
(layers=(), loss='mse', weighted=False, rng=13)¶
Methods
__init__
([layers, loss, weighted, rng])add_layer
([layer, is_output])Add a layer to our network graph. add_loss
([loss])Add a loss function to the model. build_graph
([regularizers])Connect the layers in this network to form a computation graph. feed_forward
(x, **kwargs)Compute a forward pass of all layers from the given input. find
(which, param)Get a parameter from a layer in the network. itertrain
(train[, valid, algo, subalgo, ...])Train our network, one batch at a time. load
(filename)Load a saved network from disk. loss
(**kwargs)Return a variable representing the regularized loss for this network. monitors
(**kwargs)Return expressions that should be computed to monitor training. predict
(x, **kwargs)Compute a forward pass of the inputs, returning the network output. save
(filename)Save the state of this network to a pickle file on disk. score
(x, y[, w])Compute R^2 coefficient of determination for a given labeled input. set_loss
(*args, **kwargs)Clear the current loss functions from the network and add a new one. train
(*args, **kwargs)Train the network until the trainer converges. updates
(**kwargs)Return expressions to run as updates during network training. Attributes
DEFAULT_OUTPUT_ACTIVATION
INPUT_NDIM
OUTPUT_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. -