theanets.trainer.SampleTrainer

class theanets.trainer.SampleTrainer(network)[source]

This trainer replaces network weights with samples from the input.

__init__(network)[source]

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

Methods

__init__(network) x.__init__(…) initializes x; see help(type(x)) for signature
itertrain(train[, valid]) Train a model using a training and validation set.
reservoir(xs, n, rng) Select a random sample of n items from xs.
itertrain(train, valid=None, **kwargs)[source]

Train a model using a training and validation set.

This method yields a series of monitor values to the caller. After every iteration, a pair of monitor dictionaries is generated: one evaluated on the training dataset, and another evaluated on the validation dataset. The validation monitors might not be updated during every training iteration; in this case, the most recent validation monitors will be yielded along with the training monitors.

Parameters:
train : Dataset

A set of training data for computing updates to model parameters.

valid : Dataset

A set of validation data for computing monitor values and determining when the loss has stopped improving.

Yields:
training : dict

A dictionary mapping monitor names to values, evaluated on the training dataset.

validation : dict

A dictionary containing monitor values evaluated on the validation dataset.

static reservoir(xs, n, rng)[source]

Select a random sample of n items from xs.