java 循环神经网络,循环卷积BLSTM神经网络 - 任意序列长度

使用Keras Theano我成功地制作了一个复发的双向LSTM神经网络,它能够训练和分类任意长度的DNA序列,使用以下模型(完整工作代码见:http://pastebin.com/jBLv8B72):

sequence = Input(shape=(None, ONE_HOT_DIMENSION), dtype='float32')

dropout = Dropout(0.2)(sequence)

# bidirectional LSTM

forward_lstm = LSTM(

output_dim=50, init='uniform', inner_init='uniform', forget_bias_init='one', return_sequences=True,

activation='tanh', inner_activation='sigmoid',

)(dropout)

backward_lstm = LSTM(

output_dim=50, init='uniform', inner_init='uniform', forget_bias_init='one', return_sequences=True,

activation='tanh', inner_activation='sigmoid', go_backwards=True,

)(dropout)

blstm = merge([forward_lstm, backward_lstm], mode='concat', concat_axis=-1)

dense = TimeDistributed(Dense(NUM_CLASSES))(blstm)

self.model = Model(input=sequence, output=dense)

self.model.compile(

loss='binary_crossentropy',

optimizer='adam',

metrics=['accuracy']

)

为了提高模型的性能,我想添加其他图层 . 最优选卷积和最大池化层 . 我做了几次尝试,但每次都失败了 . 例如,将第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)]]

显然尺寸存在问题 . 我已经尝试了重塑层,但没有成功 .

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

任何有关此事的帮助将不胜感激!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值