莫烦TensorFlow_02 Session的两种方法

import tensorflow as tf  
  
matrix1 = tf.constant([[3,3]]) # 1X2  
matrix2 = tf.constant([[2],  
               [2]])  
  
product = tf.matmul(matrix1, matrix2)  
  
  
  
#method 1  
#sess = tf.Session()  
#result = sess.run(product)  
  
#print(result)  
#sess.close()  
  
#method 2  
with tf.Session() as sess:  
  result2 = sess.run(product)  
  print(result2)  

  

posted @ 2018-03-31 21:04  路边的十元钱硬币  阅读(153)  评论(0编辑  收藏  举报