tensorflow2.0 numpy.ndarray 与tenor直接互转

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)

 

你可能感兴趣的:(tensorflow)