Keras Tensor重塑在嵌入图层后添加展平图层时出错

时间:2018-01-19 22:19:27

标签: tensorflow machine-learning keras

这是我得到的错误:

 Input to reshape is a tensor with 20480 values, but the requested shape requires a multiple of 1124073472

这是我正在使用的代码:

tmp_model = Sequential()
tmp_model.add(Embedding(1000, 64, input_length=10))
tmp_model.add(Flatten())

input_array = np.random.randint(1000, size=(32, 10))

tmp_model.compile('rmsprop', 'mse')
output_array = tmp_model.predict(input_array)

我认为没有理由为什么在嵌入后我无法展平。 你们有什么想法吗?

(tensorflow后端,不确定是否重要。)

1 个答案:

答案 0 :(得分:0)

Hobo解决这个问题的方法: 而不是使用Flatten(),我做了

tmp_model.add(Reshape((64*10,))

手动“压扁”。

但可以肯定的是,Flatten()无法正常工作!!!

相关问题