【问题标题】:Train convolutional neural network with theano/lasagne用 theano/lasagne 训练卷积神经网络
【发布时间】:2016-07-21 19:07:55
【问题描述】:

我正在尝试使用 theano/lasagne 实现 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 上获得模型的输出。我该怎么做?

(CNN 构建代码:http://pastebin.com/Gd35RncU

【问题讨论】:

    标签: python machine-learning theano conv-neural-network lasagne


    【解决方案1】:

    以下代码 sn-p 适用于我:

     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)
    

    您没有发布整个代码,但您可以检查是否在脚本中将 input_var 变量传递给 build_cnn 函数。如果您不这样做,那么 input_var 将不会成为您计算图的一部分,这就是 Theano 引发错误的原因。

    【讨论】:

      猜你喜欢
      • 2018-05-01
      • 2014-09-05
      • 2019-01-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-10
      • 2016-08-17
      • 2017-08-31
      相关资源
      最近更新 更多