写一个常规问题:如何将不同的矩阵转换为张量对象

如何将不同的矩阵转换为张量对象?

import numpy as np
import tensorflow as tf
matrix1=[[1.0,2.0],[3.0,40]]
matrix2=np.array([[1.0,2.0],[3.0,40]],dtype=np.float32)
matrix3=tf.constant([[1.0,2.0],[3.0,40]])


print(type(matrix1))
print(type(matrix2))
print(type(matrix3))

tensorForM1=tf.convert_to_tensor(matrix1,dtype=tf.float32)
tensorForM2=tf.convert_to_tensor(matrix2,dtype=tf.float32)
tensorForM3=tf.convert_to_tensor(matrix3,dtype=tf.float32)

print(type(tensorForM1))
print(type(tensorForM2))
print(type(tensorForM3))

你可能感兴趣的:(神经网络)