tensorflow之cast

tf.cast(x,dtype,name)

此函数的目的是为了将x数据,准换为dtype所表示的类型,例如tf.float32,tf.bool,tf.uint8等

示例

x = tf.Variable([True,True,False,False])
y = tf.cast(x,dtype = tf.float32)
sess = tf.Session()
init = tf.global_variables_initializer()
sess.run(init)
print(sess.run(y))

输出如下:

猜你喜欢

转载自blog.csdn.net/g0415shenw/article/details/85777745