Tensorflow学习笔记(二)Session使用

import tensorflow as tf
import os 
import numpy as np

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'  # 忽略警告

matrixl1 = tf.constant([[3, 3]])
matrixl2 = tf.constant([[2], [2]])
product = tf.matmul(matrixl1, matrixl2) # 矩阵乘法

## 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)

 

你可能感兴趣的:(Tensorflow)