美文网首页
tf2. session

tf2. session

作者: 球球之家 | 来源:发表于2017-07-14 15:22 被阅读0次
    import sys
    print(sys.version)
    '''
    3.5.3 |Continuum Analytics, Inc.| (default, May 15 2017, 10:43:23) [MSC v.1900 64 bit (AMD64)]
    '''
    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)
        print(result2)
    # [[12]]
    

    相关文章

      网友评论

          本文标题:tf2. session

          本文链接:https://www.haomeiwen.com/subject/vztohxtx.html