【发布时间】:2022-11-01 21:09:07
【问题描述】:
上次当我训练 dnn 模型时,我注意到当我尝试使用张量(dtype = float64)训练我的模型时,它总是会出错,但是当我使用具有相同规格(形状、值、dtype)的 numpy 数组训练模型时张量它没有显示错误。为什么会这样
对于作为张量的特征和标签,将第二个脚本中的 numpy.arrays 替换为:
celsius_q = tf.Variable([-40, -10, 0, 8, 15, 22, 38], tf.float64)
fahrenheit_a = tf.Variable([-40, 14, 32, 46, 59, 72, 100], tf.float64)
当使用特征和标签作为张量时,它会显示这个错误:
Error: ValueError: Failed to find data adapter that can handle input:
<class 'tensorflow.python.ops.resource_variable_ops.ResourceVariable'>,
<class 'tensorflow.python.ops.resource_variable_ops.ResourceVariable'>
【问题讨论】:
-
请查看如何创建minimal reproducible example。您应该发布导致错误的最小可执行代码
-
不要使用
tf.Variable作为输入。使用tf.constant创建张量,例如celsius_q = tf.constant([-40, -10, 0, 8, 15, 22, 38], tf.float64)
标签: numpy tensorflow machine-learning deep-learning data-science