会话怎么在TensorFlow中使用

  介绍

本篇文章为大家展示了会话怎么在TensorFlow中使用,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

<强> TensorFlow会话

在TensorFlow中是通过会话进行交互的,使用会话有两种方法。下面通过一个简单的例子(两个矩阵相乘)说一下

{(3,1)与{[5,2]相乘

[1, 2]}, (2、4)}

<强>代码

#=utf - 8编码   import  tensorflow  as  tf      时间=matrix1  tf.constant ([[3, 1], [1、2]])   时间=matrix2  tf.constant ([[5, 2], [2、4]])      时间=product  tf.matmul (matrix1 matrix2), #矩阵乘法      # session  method  1   时间=sess  tf.Session ()   时间=result  sess.run(产品)   打印(结果)   sess.close ()      # session  method  2   with  tf.Session (), as  sess2:=,,result2  sess2.run(产品)   ,打印(result2)

<强>结果

会话怎么在TensorFlow中使用“> </p> <p类=敖樯堋?上述内容就是会话怎么在TensorFlow中使用,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注行业资讯频道。</p><h2 class=会话怎么在TensorFlow中使用