tf.contrib.layers.flatten.md 743 字节
Newer Older
Z
zhoukunsheng 已提交
1 2
## tf.contrib.layers.flatten

J
jiangjiajun 已提交
3
### [tf.contrib.layers.flatten](https://www.tensorflow.org/versions/r1.13/api_docs/python/tf/contrib/layers/flatten)
Z
zhoukunsheng 已提交
4 5 6 7 8 9 10 11 12

```python
tf.contrib.layers.flatten(
    inputs,
    outputs_collections=None,
    scope=None
)
```

J
jiangjiajun 已提交
13
### [paddle.fluid.layers.flatten](http://paddlepaddle.org/documentation/docs/zh/1.4/api_cn/layers_cn.html#flatten)
Z
zhoukunsheng 已提交
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36

```python
paddle.fluid.layers.flatten(
    x, 
    axis=1, 
    name=None
)
```

### 功能差异

#### 计算方式

TensorFlow:固定第0维,将其他维合并;  

PaddlePaddle:使用`axis`指定两次合并的维度边界,参考下面示例。

### 代码示例
```
# 张量x的shape为 [2, 3, 4, 5]
out = fluid.layers.flatten(x, axis=2)
out.shape # [2*3, 4*5]

J
jiangjiajun 已提交
37
```