简体   繁体   English

用theano /烤宽面条训练卷积神经网络

[英]Train convolutional neural network with theano/lasagne

I'm trying to implement a CNN using theano/lasagne. 我正在尝试使用theano / lasagne实现CNN。 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. 这就是我试图以current_states作为输入来获取网络输出的方式。

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? 为什么不使用current_states?

I want to get the output of the model on the current_states. 我想在current_states上获取模型的输出。 How do I do this? 我该怎么做呢?

(the CNN build code: http://pastebin.com/Gd35RncU ) (CNN构建代码: 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. 您没有发布整个代码,但是可以检查一下是否在脚本中将input_var变量传递给了build_cnn函数。 If you do not, then input_var will not be part of your computational graph, which is why Theano is raising the error. 如果不这样做,那么input_var将不会成为您的计算图的一部分,这就是Theano引发错误的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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