# tensorflow | 维度转换

## shape 计算维度

`tf.shape(input,name = None)`

### 案例1

```a = tf.constant([i for i in range(20)],shape =[2,2,5])
with tf.Session() as sess:
print (sess.run(tf.shape(a)))```

## size 计算元素个数

`tf.size(input,name = None)`

### 案例2

```a = tf.constant([i for i in range(20)],shape =[2,2,5])
with tf.Session() as sess:
print (sess.run(tf.size(a)))```

## rank 计算秩

`tf.rank(input, name=None)`

### 案例3

```a = tf.constant([i for i in range(20)],shape =[2,2,5])
with tf.Session() as sess:
print (sess.run(tf.rank(a)))```

## reshape重新的规则排列

`tf.reshape(tensor, shape, name=None)`

### 案例4

```a = tf.constant([i for i in range(20)],shape =[2,2,5])
with tf.Session() as sess:
print (sess.run(tf.reshape(a,shape = [5,2,2])))```

## squeeze

`tf.squeeze(input, squeeze_dims=None, name=None)`

## expand_dims

`tf.expand_dims(input, dim, name=None)`

176 篇文章40 人订阅

0 条评论

## 相关文章

12820

26060

20570

### 基于tensorflow+DNN的MNIST数据集手写数字分类预测

DNN是deep neural network的简称，中文叫做深层神经网络，有时也叫做多层感知机（Multi-Layer perceptron,MLP）。 从...

38330

39730

30560

24640

38560

223100