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 全配置(一)