Search code examples
pythonnumpytheanolasagne

Saving theano/lasagne output parameters for future classification


I am trying to save my output parameters so I can continue training/ classifying at a later date.

I am currently using:

np.savez('model.npz', *lasagne.layers.get_all_param_values(network))

with np.load('model.npz') as f:
    param_values = [f['arr_%d' % i] for i in range(len(f.files))]
lasagne.layers.set_all_param_values(network, param_values)

as suggested here. But despite importing get_all_param_values from lasagne, I keep getting the error:

AttributeError: 'TensorVariable' object has no attribute 'get_params'

The layer I'm trying to save is:

    train_out = lasagne.layers.get_output(output, {input_var:x1, input2_var:x2, 
input3_var:x3}, deterministic=False)

Am I doing something wrong?


Solution

  • Assuming that

    output
    

    in your above code is your actual output layer, you should pass this layer to

    get_all_params(...)
    

    Passing

    train_out
    

    to it won't work, since the result of

    get_params(...)
    

    is a theano TensorVariable (as stated in the error message), not a lasagne.Layer object.