Keras throws `'Tensor' object has no attribute '_keras_shape'` when splitting a layer output

时光毁灭记忆、已成空白 提交于 2019-12-01 23:30:00

Keras adds some info to tensors when they're processed in layers. Since you're splitting the tensor outside layers, it loses that info.

The solution involves returning the split tensors from Lambda layers:

x_A = Lambda(lambda x: x[:,0], output_shape=notNecessaryWithTensorflow)(x)
x_B = Lambda(lambda x: x[:,1], output_shape=notNecessaryWithTensorflow)(x)
x_A = Reshape((1,EMBEDDING_DIM))(x_A)
x_B = Reshape((1,EMBEDDING_DIM))(x_B)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!