Advertisement

Tensorflow-WeekMao-Fan-TensorFlow Notes Simplified

阅读量:

地址:https://morvanzhou.github.io/tutorials/machine-learning/tensorflow/
代码获取路径:https://github.com/MorvanZhou/tutorials/tree/master/tensorflowTUT

Tensorflow 6 Session 会话控制 :

Session的两种启动方式

复制代码
    import tensorflow as tf
    # create two matrixes
    matrix1 = tf.constant([[3,3]])
    matrix2 = tf.constant([[2],
                       [2]])
    product = tf.matmul(matrix1,matrix2)
    
    # method 1
    sess = tf.Session()
    result = sess.run(product)
    print(result)
    sess.close()
    # [[12]]
    
    # method 2
    with tf.Session() as sess:
    result2 = sess.run(product)

全部评论 (0)

还没有任何评论哟~