Leopold·Lin 2020-12-04 21:21 采纳率: 0%
浏览 374

Tensorflow

Model was constructed with shape (None, 28, 28) for input Tensor("flatten_input:0", shape=(None, 28, 28), dtype=float32), but it was called on an input with incompatible shape (None, 28).

这个问题怎么解决,

  • 写回答

1条回答 默认 最新

  • 233彭于晏 2021-01-11 20:47
    关注

    这种情况一般是输入对不上,检查下tfrecorf的输入名字和input layer里面name应该有没对齐的。

    我之前也遇到同样的问题,我模型定义某个输入时写的是

    neg_item_sample_input = Input(shape=(neg_sample_num,), name="neg_item", dtype='string')

    但是我tf-record里面写的变量名字是

    feature_spec["neg_sample"] = tf.io.FixedLenFeature([], tf.string)

    这里面neg_sample 和 neg_item就没对上,导致模型在called的时候变量shape会乱掉

    附上我的当时报错信息

    WARNING:tensorflow:Model was constructed with shape (None, 1) for input Tensor("zodiac:0", shape=(None, 1), dtype=string), but it was called on an input with incompatible shape (None, 20).
    WARNING:tensorflow:Model was constructed with shape (None, 20) for input Tensor("item_id_hist:0", shape=(None, 20), dtype=string), but it was called on an input with incompatible shape (None, 1).
    WARNING:tensorflow:Model was constructed with shape (None, 1) for input Tensor("item_id:0", shape=(None, 1), dtype=string), but it was called on an input with incompatible shape (None, 10).
    WARNING:tensorflow:Model was constructed with shape (None, 10) for input Tensor("neg_item:0", shape=(None, 10), dtype=string), but it was called on an input with incompatible shape (None, 1)

    可以看到我的变量好几个shape都乱掉了,一个对不上会影响很多

    参考:https://www.cnblogs.com/oaks/p/14043877.html

    评论

报告相同问题?

悬赏问题

  • ¥15 关于PLUS模型中kapaa值的问题
  • ¥15 关于博途V17进行仿真时无法建立连接问题
  • ¥15 请问下这个红框里面是什么文档或者记事本编辑器
  • ¥15 机器学习教材中的例题询问
  • ¥15 求.net core 几款免费的pdf编辑器
  • ¥15 为什么安装HCL 和virtualbox之后没有找到VirtualBoxHost-OnlyNetWork?
  • ¥15 C# P/Invoke的效率问题
  • ¥20 thinkphp适配人大金仓问题
  • ¥20 Oracle替换.dbf文件后无法连接,如何解决?(相关搜索:数据库|死循环)
  • ¥15 数据库数据成问号了,前台查询正常,数据库查询是?号