【发布时间】:2019-12-31 08:38:41
【问题描述】:
在运行 tensorflow 时出现错误 TypeError: 'Mul' Op 的输入 'y' 的 float32 类型与参数 'x' 的 int32 类型不匹配。
我的代码是
import numpy as np
import pandas as pd
import tensorflow as tf
w = tf.Variable(0, dtype=tf.float32)
cost = tf.add(tf.add(w**2, tf.multiply(-10,w)), 25)
train = tf.train.GradientDescentOptimizer(0.001).minimize(cost)
init = tf.global_variables_initializer()
session = tf.session()
session.run(init)
session.run(w)
我正在运行 1.2.0 版 有很多这样的问题,但不是很好的答案。 你能解释一下什么是hapening吗?提前致谢。
【问题讨论】:
标签: python-3.x tensorflow tensorflow2.0