【发布时间】:2018-03-12 17:43:30
【问题描述】:
我用 Keras 训练了一个 GRU。跑的时候报错
nxt = model.predict([features,embedding_matrix[enc_map[cur]]])
ValueError: Error when checking : expected input_2 to have shape (512,) but got array with shape (1,)
但是 特征.形状 (512,)` 还有
embedding_matrix[enc_map[cur]].shape
(50,)
以下是模型摘要:
model.summary()
________________________________________________________________________________
Layer (type) Output Shape Param # Connected to
================================================================================
input_2 (InputLayer) (None, 512) 0
________________________________________________________________________________
input_1 (InputLayer) (None, 50) 0
________________________________________________________________________________
merge_1 (Merge) (None, 562) 0 input_2[0][0]
input_1[0][0]
________________________________________________________________________________
reshape_1 (Reshape) (None, 1, 562) 0 merge_1[0][0]
________________________________________________________________________________
gru_1 (GRU) (None, 128) 265344 reshape_1[0][0]
_______________________________________________________________________________
dense_1 (Dense) (None, 50) 6450 gru_1[0][0]
================================================================================
Total params: 271,794
Trainable params: 271,794
Non-trainable params: 0
【问题讨论】:
标签: deep-learning keras keras-layer