我正在建立一个网络来排列一组N个输入。理想情况下,它们应该同时输入并共享参数。它们的目标向量应该是一个N-hot向量来匹配输入。你知道吗
这意味着我的输入应该是(批大小,N,序列长度,特征长度)
但是对于任何大于3维的输入,keras都会抛出一个错误,如下所示:
ValueError: Input 0 is incompatible with layer lstm_2: expected ndim=3, found ndim=4
我目前的keras设置是:
x = Input(shape=(72,300))
aux_input = Input(shape=(72, 4))
probs = Input(shape=(1,))
#dim_red_1 = Dense(100)(x)
dim_red_2 = Dense(20, activation='tanh')(x)
cat = concatenate([dim_red_2, aux_input])
encoded = LSTM(64)(cat)
cat2 = concatenate([encoded, probs])
output = Dense(1, activation='sigmoid')(cat2)
lstm_model = Model(inputs=[x, aux_input, probs], outputs=output)
lstm_model.compile(optimizer='ADAM', loss='binary_crossentropy', metrics=['accuracy'])
有没有办法用Keras实现这一点?你知道吗
尽管您的代码看起来不错,但请确保导入正确的包:
输出:
相关问题 更多 >
编程相关推荐