我正在尝试使用 Lasagne 构建一个 CNN,并且我有 119 个特征变量。我能够使用 Lasagne 成功构建 MLP,但是当我尝试使用以下代码添加卷积层(使用 1D 卷积)时,出现错误。难道我做错了什么?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
文件“/Users/adityanagarajan/anaconda/lib/python2.7/site-packages/lasagne/layers/dense.py”,第 63 行,在 __init__ super(DenseLayer, self).__init__(incoming, **kwargs) 文件中/Users/adityanagarajan/anaconda/lib/python2.7/site-packages/lasagne/layers/base.py”,第 35 行,在 __init__ self.input_shape = incoming.output_shape 文件“/Users/adityanagarajan/anaconda/lib/python2 .7/site-packages/lasagne/layers/base.py”,第 49 行,在 output_shape 返回 self.get_output_shape_for(self.input_shape) 文件“/Users/adityanagarajan/anaconda/lib/python2.7/site-packages/lasagne /layers/conv.py",第 237 行,在 get_output_shape_for output_length = conv_output_length(input_shape[2], IndexError: tuple index out of range