tf.convert_to_tensor()函数的使用 | 数据类型转换
#将python的数据类型(列表和矩阵)转换成TensorFlow可用的tensor数据类型
import tensorflow as tf
import numpy as np
A = [1,2,3]
B = np.array([1,2,3])
C = tf.convert_to_tensor(A)
D = tf.convert_to_tensor(B)
print(type(A), A)
print(type(B), B)
print(type(C), C)
print(type(D), D)
结果
<class 'list'> [1, 2, 3]
<class 'numpy.ndarray'> [1 2 3]
<class 'tensorflow.python.framework.ops.EagerTensor'> tf.Tensor([1 2 3], shape=(3,), dtype=int32)
<class 'tensorflow.python.framework.ops.EagerTensor'> tf.Tensor([1 2 3], shape=(3,), dtype=int32)
因上求缘,果上努力~~~~ 作者:图神经网络,转载请注明原文链接:https://www.cnblogs.com/BlairGrowing/p/15938828.html