我正在尝试实现一个使用theano/千层面的CNN。我制作了一个神经网络,但不知道如何根据当前状态对其进行训练。
这就是我试图以current_states作为输入来获取网络输出的方法。
train = theano.function([input_var], lasagne.layers.get_output(l.out))
output = train(current_states)然而,我得到了这个错误:
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'.为什么不使用current_states?
我想在current_states上获得模型的输出。我该怎么做呢?
(美国有线电视新闻网的构建代码:http://pastebin.com/Gd35RncU)
发布于 2016-04-02 21:42:25
下面的代码片段适用于我:
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)您没有发布完整的代码,但是您可以检查脚本中是否向build_cnn函数传递了input_var变量。如果您不这样做,那么input_var将不会是您的计算图的一部分,这就是Theano引发错误的原因。
https://stackoverflow.com/questions/36365425
复制相似问题