我正在尝试构建一个卷积神经网络,这是我的代码:
def build_cnn(input_var=None):
network = lasagne.layers.InputLayer(shape=(None ,1 ,700, 21),
input_var=input_var)
batchsize, seqlen, _, _ = network.input_var.shape
network = lasagne.layers.Conv2DLayer(
network, num_filters=32, filter_size=(5, 5),
nonlinearity=lasagne.nonlinearities.sigmoid,
W=lasagne.init.GlorotUniform())
network = lasagne.layers.MaxPool2DLayer(network, pool_size=(2, 2))
network = lasagne.layers.Conv2DLayer(
network, num_filters=32, filter_size=(5, 5),
nonlinearity=lasagne.nonlinearities.sigmoid)
network = lasagne.layers.MaxPool2DLayer(network, pool_size=(2, 2))
network = lasagne.layers.DenseLayer(
lasagne.layers.dropout(network, p=.5),
num_units=256,
nonlinearity=lasagne.nonlinearities.sigmoid)
network = lasagne.layers.DenseLayer(
lasagne.layers.dropout(network, p=.5),
num_units=8,
nonlinearity=lasagne.nonlinearities.softmax)
l_out = lasagne.layers.ReshapeLayer(network, (batchsize*seqlen, 1, 700, 8))
return l_out
我在训练期间从train_fn()继续收到此错误:
ValueError: total size of new array must be unchanged
Apply node that caused the error: Reshape{3}(SoftmaxWithBias.0, Join.0)
Toposort index: 52
Inputs types: [TensorType(float64, matrix), TensorType(int64, vector)]
Inputs shapes: [(500, 8), (3,)]
Inputs strides: [(64, 8), (8,)]
Inputs values: ['not shown', array([500, 700, 8], dtype=int64)]
Outputs clients: [[InplaceDimShuffle{0,x,1,2}(Reshape{3}.0)]]
如有必要,我可以提供更多详细信息