为什么 tensorflow 将值的 one_hot 加倍?
Why does tensorflow doubles the one_hot on values?
我在Python中有以下测试程序:
import tensorflow as tf
sess = tf.InteractiveSession()
# Some tensor we want to print the value of
a = tf.one_hot(1,5)
# Add print operation
a = tf.Print(a, [a], message = "This is a: ")
# Add more elements of the graph using a
b = tf.add(a, a)
b.eval()
我调用了一个函数来创建一个很好的热编码。我希望输出是:
array([0., 1., 0., 0., 0.], dtype=float32)
但输出是:
array([0., 2., 0., 0., 0.], dtype=float32)
为什么?
您正在将 a
添加到自身,然后打印添加。所以本质上... a= 1; print (a+a)
显然不是这么写的,但我确实希望1+1等于2。
我在Python中有以下测试程序:
import tensorflow as tf
sess = tf.InteractiveSession()
# Some tensor we want to print the value of
a = tf.one_hot(1,5)
# Add print operation
a = tf.Print(a, [a], message = "This is a: ")
# Add more elements of the graph using a
b = tf.add(a, a)
b.eval()
我调用了一个函数来创建一个很好的热编码。我希望输出是:
array([0., 1., 0., 0., 0.], dtype=float32)
但输出是:
array([0., 2., 0., 0., 0.], dtype=float32)
为什么?
您正在将 a
添加到自身,然后打印添加。所以本质上... a= 1; print (a+a)
显然不是这么写的,但我确实希望1+1等于2。