简体   繁体   中英

Train convolutional neural network with theano/lasagne

I'm trying to implement a CNN using theano/lasagne. I've made a neural network but can't figure out how to train it with the current state.

This is how I'm trying to get the output of the network with the current_states as input.

train = theano.function([input_var], lasagne.layers.get_output(l.out))
output = train(current_states)

However I get this error:

theano.compile.function_module.UnusedInputError: theano.function was asked to create a function computing outputs given certain inputs, but the provided input variable at index 0 is not part of the computational graph needed to compute the outputs: inputs.
To make this error into a warning, you can pass the parameter on_unused_input='warn' to theano.function. To disable it completely, use on_unused_input='ignore'.

Why is current_states not used?

I want to get the output of the model on the current_states. How do I do this?

(the CNN build code: http://pastebin.com/Gd35RncU )

The following code snippet works for me:

 import lasagne, theano
 import theano.tensor as T
 import numpy as np
 input_var = theano.tensor.tensor4('inputs')
 l_out = build_cnn(input_var)
 train = theano.function([input_var], lasagne.layers.get_output(l_out))
 x = np.random.randn(10, 4, 80, 80).astype(theano.config.floatX)
 train(x)

You didn't post your entire code, but you can check to see if in your script you are passing in the input_var variable to your build_cnn function. If you do not, then input_var will not be part of your computational graph, which is why Theano is raising the error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM