tf.keras遇见的坑:Output tensors to a Model must be the output of a TensorFlow `Layer`
生活随笔
收集整理的这篇文章主要介绍了
tf.keras遇见的坑:Output tensors to a Model must be the output of a TensorFlow `Layer`
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
经过网上查找,找到了问题所在:在使用keras编程模式是,中间插入了tf.reshape()方法便遇到此问题。
解决办法:对于遇到相同问题的任何人,可以使用keras的Lambda层来包装张量流操作,这是我所做的:
embed1 = keras.layers.Embedding(10000, 32)(inputs)# embed = keras.layers.Reshape(-1,256, 32, 1)(embed1) # embed = tf.reshape(embed1, [-1, 256, 32, 1]) def reshapes(embed1):embed = tf.reshape(embed1, [-1, 256, 32, 1])return embed embed = keras.layers.Lambda(reshapes)(embed1)
转载于:https://www.cnblogs.com/jqpy1994/p/11433746.html
总结
以上是生活随笔为你收集整理的tf.keras遇见的坑:Output tensors to a Model must be the output of a TensorFlow `Layer`的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 自己挖的坑自己填--JVM报内存溢出
- 下一篇: Maven pom.xml 全配置(一)