类型转化
tf.string_to_number(string_tensor, out_type=None, name=None): 将字符串转化为tf.float32(默认)和tf.int32
tf.to_double(x, name='ToDouble'):转化为tf.float64
tf.to_float(x, name='ToFloat'):转化为tf.float32
tf.to_int32(x, name='ToInt32'):转化为tf.int32
tf.to_int64(x, name='ToInt64'):转化为tf.int64
tf.cast(x, dtype, name=None):转化为dtype指定的类型
形状转化
tf.reshape(tensor, shape, name=None):转化为新shape,若有一个维度设置为-1,会自动推导
本文介绍了TensorFlow中常见的数据类型转换方法,包括字符串到数值类型的转换及不同数值类型之间的相互转换,并展示了如何使用这些函数来调整张量的形状。

935

被折叠的 条评论
为什么被折叠?



