TensorFlow 学习(六) —— TensorFlow 与 numpy 的交互

                       

1. 将 numpy 下的多维数组(ndarray)转化为 tensor

a = np.zeros((3, 3))ta = tf.convert_to_tensor(a)with tf.Session() as sess:    print(sess.run(ta))
   
   
  • 1
  • 2
  • 3
  • 4

2. 求均值

  • 对于一个 numpy 下的多维数组,求均值:correct.mean()
  • 如果是 tensorflow 的一个 tensor,求均值:tf.reduce_mean(tf.cast(correct, tf.float32))
           

再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow

猜你喜欢

转载自blog.csdn.net/qq_43679627/article/details/87790996