使用以下方法构建模型:
model = Model(inputs=[input_text], outputs=pred)
出现错误:
AttributeError: 'Tensor'对象没有'_keras_shape'属性
我尝试的完整笔记本可以在这里找到... https://github.com/shantanuo/pandas_examples/blob/master/tensorflow/tf_learn.ipynb
同样的代码的纯文本版本可以在这里找到... https://gist.github.com/shantanuo/4e35baba144ee658e4dd4d1f87e19f3a
即使我使用了与此博客中显示的完全相同的代码,我仍想知道为什么会出现错误:
https://towardsdatascience.com/transfer-learning-using-elmo-embedding-c4a7e415103c
期望的输出-类似这样:
模型摘要如下: _________________________________________________________________ Layer (type) Output Shape Param #
================================================================= input_2 (InputLayer) (None, 1) 0
_________________________________________________________________ lambda_2 (Lambda) (None, 1024) 0
_________________________________________________________________ dense_3 (Dense) (None, 256) 262400
_________________________________________________________________ dense_4 (Dense) (None, 1) 257
我尝试升级tensorflow和keras,但仍然出现相同的错误:
!pip install --upgrade tensorflow