【问题标题】:TypeError: Fetch argument 12434120.0 has invalid type <class 'numpy.float32'>, must be a string or Tensor. (in Tensorflow)TypeError: Fetch argument 12434120.0 has invalid type <class 'numpy.float32'>,必须是字符串或张量。 (在张量流中)
【发布时间】:2021-01-14 13:42:35
【问题描述】:

我在训练一个多元线性回归模型,出现了这个错误码。

TypeError: Fetch argument 12434120.0 has invalid type <class 'numpy.float32'>, must be a string or Tensor. (Can not convert a float32 into a Tensor or Operation.)

我想知道这是什么意思... 训练代码是这样的:

for step in range(100001):
    cost_, hypo_, _ = sess.run([cost, hypothesis, train], feed_dict={X: x_data,Y: y_data})
    if step % 500 == 0:
        print('#', step, 'loss:', cost_))
        print('-price of cabbage:', hypo_[0])

【问题讨论】:

    标签: tensorflow tensorflow2.0


    【解决方案1】:

    我重启了内核,突然就可以了……我觉得问题是'cost'这个名字的重复,所以我把它改成了'cost_'

    【讨论】:

      猜你喜欢
      • 2018-07-25
      • 2018-01-23
      • 1970-01-01
      • 2016-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-21
      相关资源
      最近更新 更多