https://www.w3cschool.cn/tensorflow_python/tensorflow_python-gnwm2c68.htmlhtml
[1] 安裝Tensorflow(Linux ubuntu) http://blog.csdn.net/lenbow/article/details/51203526
[2] ubuntu下CUDA編譯的GCC降級安裝 http://blog.csdn.net/lenbow/article/details/51596706
[3] ubuntu手動安裝最新Nvidia顯卡驅動 http://blog.csdn.net/lenbow/article/details/51683783
[4] Tensorflow的CUDA升級,以及相關配置 http://blog.csdn.net/lenbow/article/details/52118116
[5] 基於gensim的Doc2Vec簡析 http://blog.csdn.net/lenbow/article/details/52120230
[6] TensorFlow的分佈式學習框架簡介 http://blog.csdn.net/lenbow/article/details/52130565
[7] Tensorflow一些經常使用基本概念與函數(1) http://blog.csdn.net/lenbow/article/details/52152766
[8] Tensorflow一些經常使用基本概念與函數(2) http://blog.csdn.net/lenbow/article/details/52181159
[9] Tensorflow一些經常使用基本概念與函數(3) http://blog.csdn.net/lenbow/article/details/52213105python
import tensorflow as tf input = tf.constant([[0,1,2],[3,4,5]]) print(type(input.shape)) print(type(input.get_shape())) print(type(tf.shape(input)))
Out: <class 'tensorflow.python.framework.tensor_shape.TensorShape'> <class 'tensorflow.python.framework.tensor_shape.TensorShape'> <class 'tensorflow.python.framework.ops.Tensor'>
能夠看到s.shape和x.get_shape()都是返回TensorShape類型對象,而tf.shape(x)返回的是Tensor類型對象。ubuntu
所以要想得到維度信息,則須要調用TensorShape的ts.as_list()方法,返回的是Python的list:框架
input.shape.as_list() # Out: [2,3] input.get_shape().as_list() # Out: [2,3]
此外,還能夠得到維度的個數:分佈式
input.shape.ndims # Out: 2 input.get_shape().ndims # Out: 2
tf.rank(input) # Out: type=Tensor, value=2
得到Python原生類型的維度信息:函數
input.shape.as_list() # [2,3] input.shape.ndims # 2
得到TensorFlow中Tensor類型的維度信息:學習
tf.shape(input) tf.rank(input)