flatten

    • 参数:
      • axis (int) - flatten展开的分割轴,[0, axis) 轴数据被flatten到输出矩阵的0轴,[axis, R)数据被flatten到输出矩阵的1轴,其中R是输入张量的总维度数。axis的值必须在[0,R]范围内。当 axis=0 时,若输入Tensor的维度为 ,则输出张量的Tensor维度为 flatten - 图2 ,默认值为1。
      • name (str,可选) - 具体用法请参见 ,一般无需设置,默认值为None。
    • 抛出异常:
      • ValueError: 如果axis的范围不在 [0, rank(x)] 范围内
    1. import paddle.fluid as fluid
    2. x = fluid.layers.data(name="x", shape=[4, 4, 3], append_batch_size=False, dtype="float32")
    3. # x shape is [4, 4, 3]
    4. # out shape is [16, 3]