1、代码参考
import numpy as np import tensorflow as tf a = np.random.random((5,3)) b = np.random.randint(0,9,(3,1)) c = tf.tensordot(a.astype(np.float),b.astype(np.float),axes=1) # tensor 转ndarray dn = c.numpy() print(dn) # ndarray转tensor tn = tf.convert_to_tensor(dn) print(tn)