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

前端 未结 21 1869
爱一瞬间的悲伤
爱一瞬间的悲伤 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:15

    Enable the eager execution which is introduced in tensorflow after version 1.10. It's very easy to use.

    # Initialize session
    import tensorflow as tf
    tf.enable_eager_execution()
    
    
    # Some tensor we want to print the value of
    a = tf.constant([1.0, 3.0])
    
    print(a)
    

提交回复
热议问题