Python 3.x 递归卷积BLSTM神经网络-任意序列长度

Python 3.x 递归卷积BLSTM神经网络-任意序列长度,python-3.x,theano,keras,lstm,recurrent-neural-network,Python 3.x,Theano,Keras,Lstm,Recurrent Neural Network,使用Keras+Theano,我成功地构建了一个递归双向LSTM神经网络,该网络能够使用以下模型对任意长度的DNA序列进行训练和分类(完整工作代码请参见:): 为了提高模型的性能,我想添加额外的层。最好是卷积层和最大池层。我试了几次,但每次都失败了。例如,将第2行更改为以下3行: convolution = Convolution1D(filter_length=6, nb_filter=10)(sequence) max_pooling = MaxPooling1D(pool_length=2

使用Keras+Theano,我成功地构建了一个递归双向LSTM神经网络,该网络能够使用以下模型对任意长度的DNA序列进行训练和分类(完整工作代码请参见:):

为了提高模型的性能,我想添加额外的层。最好是卷积层和最大池层。我试了几次,但每次都失败了。例如,将第2行更改为以下3行:

convolution = Convolution1D(filter_length=6, nb_filter=10)(sequence)
max_pooling = MaxPooling1D(pool_length=2)(convolution)
dropout = Dropout(0.2)(max_pooling)
模型已编译,但抛出错误:

ValueError: Input dimension mis-match. (input[0].shape[1] = 111, input[1].shape[1] = 53)
Apply node that caused the error: Elemwise{Composite{((i0 * log(i1)) + (i2 * log(i3)))}}(timedistributed_1_target, Elemwise{clip,no_inplace}.0, Elemwise{sub,no_inplace}.0, Elemwise{sub,no_inplace}.0)
Toposort index: 546
Inputs types: [TensorType(float32, 3D), TensorType(float32, 3D), TensorType(float32, 3D), TensorType(float32, 3D)]
Inputs shapes: [(1L, 111L, 2L), (1L, 53L, 2L), (1L, 111L, 2L), (1L, 53L, 2L)]
Inputs strides: [(888L, 8L, 4L), (424L, 8L, 4L), (888L, 8L, 4L), (424L, 8L, 4L)]
Inputs values: ['not shown', 'not shown', 'not shown', 'not shown']
Outputs clients: [[Sum{axis=[1, 2], acc_dtype=float64}(Elemwise{Composite{((i0 * log(i1)) + (i2 * log(i3)))}}.0)]]
显然,尺寸有问题。我尝试过重塑图层,但没有成功

甚至可以在任意序列长度的上下文中使用卷积和/或最大池层吗

在此问题上的任何帮助都将不胜感激

ValueError: Input dimension mis-match. (input[0].shape[1] = 111, input[1].shape[1] = 53)
Apply node that caused the error: Elemwise{Composite{((i0 * log(i1)) + (i2 * log(i3)))}}(timedistributed_1_target, Elemwise{clip,no_inplace}.0, Elemwise{sub,no_inplace}.0, Elemwise{sub,no_inplace}.0)
Toposort index: 546
Inputs types: [TensorType(float32, 3D), TensorType(float32, 3D), TensorType(float32, 3D), TensorType(float32, 3D)]
Inputs shapes: [(1L, 111L, 2L), (1L, 53L, 2L), (1L, 111L, 2L), (1L, 53L, 2L)]
Inputs strides: [(888L, 8L, 4L), (424L, 8L, 4L), (888L, 8L, 4L), (424L, 8L, 4L)]
Inputs values: ['not shown', 'not shown', 'not shown', 'not shown']
Outputs clients: [[Sum{axis=[1, 2], acc_dtype=float64}(Elemwise{Composite{((i0 * log(i1)) + (i2 * log(i3)))}}.0)]]