首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用theano/lasagne训练卷积神经网络

用theano/lasagne训练卷积神经网络
EN

Stack Overflow用户
提问于 2016-04-02 04:35:22
回答 1查看 367关注 0票数 0

我正在尝试实现一个使用theano/千层面的CNN。我制作了一个神经网络,但不知道如何根据当前状态对其进行训练。

这就是我试图以current_states作为输入来获取网络输出的方法。

代码语言:javascript
复制
train = theano.function([input_var], lasagne.layers.get_output(l.out))
output = train(current_states)

然而,我得到了这个错误:

代码语言:javascript
复制
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)

EN

回答 1

Stack Overflow用户

发布于 2016-04-02 21:42:25

下面的代码片段适用于我:

代码语言:javascript
复制
 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引发错误的原因。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36365425

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档