【问题标题】:Error: The shape of dict['input'] provided in model.execute(dict) must be [-1,128,128,3], but was [-1,128,128,3] in Tensorflow JS错误:model.execute(dict) 中提供的 dict['input'] 的形状必须是 [-1,128,128,3],但在 Tensorflow JS 中是 [-1,128,128,3]
【发布时间】:2021-07-28 02:26:40
【问题描述】:

我正在使用 tensorflow js 运行一个简单的基准测试应用程序。遇到这个非常奇怪的错误。

我创建了我的输入形状input_shape = model.inputs[0].shape

然后创建一个 zeros 数组作为模型var zeros = tf.zeros([input_shape]);的虚拟输入

然后调用await timeModelInference(model, zeros, 1) 会在标题中产生错误。

util_base.js:153 Uncaught (in promise) Error: The shape of dict['input'] provided in model.execute(dict) must be [-1,128,128,3], but was [-1,128,128,3]
    at Vv (util_base.js:153)
    at graph_executor.js:572
    at Array.forEach (<anonymous>)
    at e.t.checkInputShapeAndType (graph_executor.js:563)
    at e.<anonymous> (graph_executor.js:345)
    at c (runtime.js:63)
    at Generator._invoke (runtime.js:293)
    at Generator.next (runtime.js:118)
    at bv (runtime.js:747)
    at o (runtime.js:747)

我尝试将第一个维度更改为 [1,128,128,3] 或 [,128,128,3] 无济于事。

谢谢。

【问题讨论】:

    标签: tensorflow tensorflow.js


    【解决方案1】:

    在调试了一下之后,问题是我调用了tf.zeros([input_shape]) 而不是tf.zeros(input_shape) 这种额外的数组包装导致了问题,即使形状完全相同。下次最好小心点。 :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-28
      • 1970-01-01
      • 2020-06-01
      • 1970-01-01
      • 2021-06-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多