Tensorflow中张量数据类型的转换

来源:互联网 发布:linux 压缩 编辑:程序博客网 时间:2024/06/07 06:31
字符串转为数字:tf.string_to_number(string_tensor, out_type=None, name=None)
转为64位浮点类型–float64:tf.to_double(x, name=’ToDouble’)
转为32位浮点类型–float32:tf.to_float(x, name=’ToFloat’)
转为32位整型–int32:tf.to_int32(x, name=’ToInt32’)
转为64位整型–int64:tf.to_int64(x, name=’ToInt64’)
将x或者x.values转换为dtype# tensor a is [1.8, 2.2], dtype=tf.float# tf.cast(a, tf.int32) ==> [1, 2],dtype=tf.int32tf.cast(x, dtype, name=None)
原创粉丝点击