tensorflow,即是 tensor flows,在 computation graph 中 flows(流动)的不是别人,正是 tensor;

1. tensor 基本属性

  • tensor 的名字:t.op.name
  • tensor 的尺寸:t.get_shape().as_list()

    W = tf.Variable(tf.zeros([784, 10]), name='Weight')
    W.op.name
        # Weight
    W.get_shape().as_list()
        # [784, 10]
    
    W.get_shape() # 该函数返回的对象也有丰富的成员函数
        W.get_shape()[:2].num_elements()
    
    x = tf.placeholder(tf.float32, [None, 784], name='input')
    x.op.name
        # input
    x.get_shape().as_list()
        # [None, 784]
  • t.get_shape()[-1].value:获得其具体的属性值;

2. 基本数据类型

  • DT_FLOAT,tf.float32
  • DT_INT16,tf.int16
  • DT_INT32,tf.int32
  • DT_INT64,tf.int64
  • DT_STRING, tf.string
  • DT_BOOL, tf.bool
posted on 2017-03-11 12:51  未雨愁眸  阅读(195)  评论(0编辑  收藏  举报