Tensorflow

TensorFlow学习笔记(15)tenforflow打印te

2018-11-20  本文已影响0人  谢昆明

github代码

  import tensorflow as tf                                                                                                    
  import numpy as np                                                                                                         
                                                                                                                             
  with tf.Session() as sess:                                                                                                 
      x = tf.constant([[1, 2, 4], [8, 16, 32]]) # 2x2 matrix                                                                 
                                                                                                                             
      #  Tensor("Const:0", shape=(2, 3), dtype=int32)                                                                        
      print(x)                                                                                                               
                                                                                                                             
      # 方法1                                                                                                                
      #  [[ 1  2  4]                                                                                                         
      #   [ 8 16 32]]                                                                                                        
      print(x.eval())                                                                                                        
                                                                                                                             
      # 方法2                                                                                                                
      #  [[ 1  2  4]                                                                                                         
      #   [ 8 16 32]]                                                                                                        
      print(sess.run(x))     
上一篇 下一篇

猜你喜欢

热点阅读