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)

  

 

相关文章:

  • 2021-11-18
  • 2021-07-03
  • 2021-05-26
  • 2022-01-07
  • 2022-12-23
  • 2021-12-09
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-08
  • 2022-02-25
相关资源
相似解决方案