【发布时间】:2016-06-23 09:10:37
【问题描述】:
我正在尝试进行逻辑回归,我的训练数据集来自一个 numpy float64 数组。我的代码看起来像,
import tensorflow as tf
graph = tf.Graph()
with graph.as_default():
examples =tf.constant(mat6) # mat6 is a numpy float64 array
t_labels = tf.constant(labels) # labels is an a numpy float64 array
W = tf.Variable(tf.truncated_normal([115713, 2]))
b = tf.Variable(tf.zeros([2]))
logits = tf.matmul(examples, W)+b
这会引发异常
TypeError: Input 'b' of 'MatMul' Op has type float32 that does not match type float64 of argument 'a'.
这可能是因为 W 和 b 是 float32 而不是 float64。有没有办法转换 W 和 b 或将其创建为 float64
【问题讨论】:
标签: python numpy machine-learning tensorflow