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

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

    Try this simple code! (it is self explanatory)

    import tensorflow as tf
    sess = tf.InteractiveSession() # see the answers above :)
    x = [[1.,2.,1.],[1.,1.,1.]]    # a 2D matrix as input to softmax
    y = tf.nn.softmax(x)           # this is the softmax function
                                   # you can have anything you like here
    u = y.eval()
    print(u)
    

提交回复
热议问题