Lasagne 1D 卷积误差

Lasagne 1D Convolution Error

我正在尝试使用烤宽面条构建 CNN,并且我有 119 个特征变量。我能够使用烤宽面条成功构建 MLP,但是当我尝试使用以下代码添加卷积层(使用一维卷积)时,出现错误。难道我做错了什么? Lasagne 中的一维卷积是否经过测试?

def build_custom_mlp(input_var, depth, width):
    network = lasagne.layers.InputLayer(shape=(None, 119), input_var=input_var)
    network = lasagne.layers.Conv1DLayer(network, num_filters=20, filter_size=10,
              stride=1, pad=1, nonlinearity=lasagne.nonlinearities.rectify)
    network = lasagne.layers.Pool1DLayer(network, pool_size=2)
    nonlin = lasagne.nonlinearities.rectify
    network = lasagne.layers.DenseLayer(network, width, nonlinearity=nonlin)
    # Output layer:
    relu = lasagne.nonlinearities.rectify
    network = lasagne.layers.DenseLayer(network, 60, nonlinearity=relu)
    return network

File "/Users/adityanagarajan/anaconda/lib/python2.7/site-packages/lasagne/layers/dense.py", line 63, in __init__ super(DenseLayer, self).__init__(incoming, **kwargs) File "/Users/adityanagarajan/anaconda/lib/python2.7/site-packages/lasagne/layers/base.py", line 35, in __init__ self.input_shape = incoming.output_shape File "/Users/adityanagarajan/anaconda/lib/python2.7/site-packages/lasagne/layers/base.py", line 49, in output_shape return self.get_output_shape_for(self.input_shape) File "/Users/adityanagarajan/anaconda/lib/python2.7/site-packages/lasagne/layers/conv.py", line 237, in get_output_shape_for output_length = conv_output_length(input_shape[2], IndexError: tuple index out of range

错误告诉你答案:

line 237, in get_output_shape_for output_length = conv_output_length(input_shape[2], IndexError: tuple index out of range

如果您检查 source,在第 237 行,一个元组试图被索引,但其中没有 3 个元素。如果您重塑数据,它应该可以解决错误,请尝试 (None, 1, 119) 作为您的输入。