tf.contrib.layers.flatten 729 字节
Newer Older
Z
zhoukunsheng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
## tf.contrib.layers.flatten

### [tf.contrib.layers.flatten](https://www.tensorflow.org/api_docs/python/tf/contrib/layers/flatten)

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

### [paddle.fluid.layers.flatten](http://paddlepaddle.org/documentation/docs/zh/1.2/api_cn/layers_cn.html#flatten)

```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]

```