我想构建这种类型的神经网络体系结构:2dcnn gru。考虑到输入是4D tensor(batch_size,1,1500,40(,然后我有3个2D-CNN层(带有批处理标准,relu,最大池和辍学(。在第三个CNN层的输出中,我获得了4D量(无,120、1500、1(。现在是我的问题,如何将GRU层与此输入形状联系起来?我试图在keras中进行重塑(因此它变成(无,1500,120((,并通过gru层进出输出,但有问题...还要考虑一下,我的培训标签是3D tensor(batch_size,1500,2(。我在此处复制KERAS模型和summary((命令的输出:
input_data = Input(shape=[1,1500,40])
x = input_data
for i in range(len([32,96,120])):
x = Conv2D(filters=[32,96,120],
kernel_size=[5,5],
activation='relu',
padding='same'
)(x)
x = BatchNormalization(axis=3)(x)
x = Dropout(0.3)(x)
x = MaxPooling2D(pool_size=[(1,5),(1,4),(1,2)],
data_format="channels_first")(x)
x = Reshape((1500, 120))(x)
x = GRU(units=120,
activation='tanh',
recurrent_activation='hard_sigmoid',
dropout=0.3,
recurrent_dropout=0.3,
)(x)
predictions = Dense(2, activation='softmax')(x)
network = Model(input_data, predictions)
network.summary()
网络摘要
你能帮我吗?谢谢
似乎您期望输入的每个时间段预测。为了获得此功能,您需要在创建GRU
层时将参数return_sequences
设置添加到True
。