How to print the value of a Tensor object in TensorFlow?

前端 未结 21 1882
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 07:44

I have been using the introductory example of matrix multiplication in TensorFlow.

matrix1 = tf.constant([[3., 3.]])
matrix2 = tf.constant([[2.],[2.]])
produ         


        
21条回答
  •  轮回少年
    2020-11-22 08:06

    import tensorflow as tf
    sess = tf.InteractiveSession()
    x = [[1.,2.,1.],[1.,1.,1.]]    
    y = tf.nn.softmax(x)           
    
    matrix1 = tf.constant([[3., 3.]])
    matrix2 = tf.constant([[2.],[2.]])
    product = tf.matmul(matrix1, matrix2)
    
    print(product.eval())
    tf.reset_default_graph()
    sess.close()
    

提交回复
热议问题