Tensorflow中Session会话控制的两种打开模式

import tensorflow as tf
matrix1=tf.constant([[3,3]]) 
matrix2=tf.constant([[2],
                     [2]])
product=tf.matmul(matrix1,matrix2)#matrix multiply np.dat(m1,m2)

#mothod 1

sess=tf.Session()
result=sess.run(product)
print(result)
sess.close()

# mothod 2

with tf.Session()as sess:
    result2=sess.run(product)
    print(result2)

转载地址

猜你喜欢

转载自blog.csdn.net/m0_37052320/article/details/80226363