最大汇集指数

时间:2016-02-25 10:20:34

标签: neural-network theano lasagne

我试图在千层面找到指数2d max pooling

network = batch_norm(Conv2DLayer(
        network, num_filters=filter_size, filter_size=(kernel, kernel),pad=pad,
        nonlinearity=lasagne.nonlinearities.rectify, 
        W=lasagne.init.GlorotUniform(),name="conv"), name="BN")
pool_in = lasagne.layers.get_output(network)
network = MaxPool2DLayer(network, pool_size=(pool_size, pool_size),stride=2,name="pool")
pool_out = lasagne.layers.get_output(network)
ind1 = T.grad(T.sum(pool_out), wrt=pool_in)

当我尝试构建模型时,会引发错误

DisconnectedInputError: grad method was asked to compute the gradient with respect to a variable that is not part of the computational graph of the cost, or is used only by a non-differentiable operator: Elemwise{mul,no_inplace}.0
Backtrace when the node is created:
  File "//anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2871, in run_cell
    interactivity=interactivity, compiler=compiler, result=result)
  File "//anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2975, in run_ast_nodes
    if self.run_code(code, result):
  File "//anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 3035, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-28-0b136cc660e2>", line 1, in <module>
    network = build_model()
  File "<ipython-input-27-20acc3fe0d98>", line 8, in build_model
    pool_in = lasagne.layers.get_output(network)
  File "//anaconda/lib/python2.7/site-packages/lasagne/layers/helper.py", line 191, in get_output
    all_outputs[layer] = layer.get_output_for(layer_inputs, **kwargs)
  File "//anaconda/lib/python2.7/site-packages/lasagne/layers/special.py", line 52, in get_output_for
    return self.nonlinearity(input)
  File "//anaconda/lib/python2.7/site-packages/lasagne/nonlinearities.py", line 157, in rectify
    return theano.tensor.nnet.relu(x)

在千层面中间输出上编码函数的正确方法是什么。

1 个答案:

答案 0 :(得分:0)

前一段时间我遇到过类似的问题,请查看我的2d和3d最大合并索引的解决方案:

Theano max_pool_3d

(基于相同的Google-groups帖子,我猜)