yadll.model

Model

yadll.model.save_model(model, file=None)[source]

Save the model to file with cPickle This function is used by the training function to save the model. Parameters ———- model : yadll.model.Model

model to be saved in file
file : string
file name
yadll.model.load_model(file)[source]

load (unpickle) a saved model

Parameters:

file : `string’

file name

Returns:

a yadll.model.Model

Examples

>>> my_model = load_model('my_best_model.ym')
class yadll.model.Model(network=None, data=None, hyperparameters=None, name='model', updates=<function sgd>, objective=<function categorical_crossentropy_error>, evaluation_metric=<function categorical_accuracy>, file=None)[source]

The yadll.model.Model contains the data, the network, the hyperparameters, and the report. It pre-trains unsupervised layers, trains the network and save it to file.

Parameters:

network : yadll.network.Network

the network to be trained

data : yadll.data.Data

the training, validating and testing set

name : string

the name of the model

updates : yadll.updates()

an update function

file : string

name of the file to save the model. If omitted a name is generated with the model name + date + time of training

compile(*args, **kwargs)[source]

Compile theano functions of the model

Parameters:

compile_arg: `string` or `List` of `string`

value can be ‘train’, ‘validate’, ‘test’, ‘predict’ and ‘all’

from_conf(conf)[source]

build model from conf object or conf file

pretrain(*args, **kwargs)[source]

Pre-training of the unsupervised layers sequentially

Returns:update unsupervised layers weights
to_conf(file=None)[source]

Save model as a conf object or conf file

train(*args, **kwargs)[source]

Training the network

Parameters:

unsupervised_training: `bool`, (default is True)

pre-training of the unsupervised layers if any

save_mode : {None, ‘end’, ‘each’}

None (default), model will not be saved unless name specified in the model definition. ‘end’, model will only be saved at the end of the training ‘each’, model will be saved each time the model is improved

early_stop : bool, (default is True)

early stopping when validation score is not improving

shuffle : bool, (default is True)

reshuffle the training set at each epoch. Batches will then be different from one epoch to another

Returns:

report