From f6cea357432acbd70f459ee35103d2c48f152f36 Mon Sep 17 00:00:00 2001 From: ying Date: Mon, 22 Jan 2018 14:12:55 +0800 Subject: [PATCH] fix rendering error of transpose operator. --- paddle/operators/transpose_op.cc | 51 ++++++++++++++------------------ 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/paddle/operators/transpose_op.cc b/paddle/operators/transpose_op.cc index 11615d806a6..c7ae162638c 100644 --- a/paddle/operators/transpose_op.cc +++ b/paddle/operators/transpose_op.cc @@ -59,44 +59,39 @@ class TransposeOpMaker : public framework::OpProtoAndCheckerMaker { : OpProtoAndCheckerMaker(proto, op_checker) { AddInput( "X", - "(Tensor)The input tensor, tensors with rank at most 6 are supported"); - AddOutput("Out", "(Tensor)The output tensor"); + "(Tensor) The input tensor, tensors with rank up to 6 are supported."); + AddOutput("Out", "(Tensor)The output tensor."); AddAttr>( "axis", - "(vector)A list of values, and the size of the list should be " - "the same with the input tensor rank, the tensor will " - "permute the axes according the the values given"); + "(vector) A list of values, and the size of the list should be " + "the same with the input tensor rank. This operator permutes the input " + "tensor's axes according to the values given."); AddComment(R"DOC( Transpose Operator. -The input tensor will be permuted according to the axis values given. -The op functions is similar to how numpy.transpose works in python. +The input tensor will be permuted according to the axes given. +The behavior of this operator is similar to how `numpy.transpose` works. -For example: +- suppose the input `X` is a 2-D tensor: + $$ + X = \begin{pmatrix} + 0 &1 &2 \\ + 3 &4 &5 + \end{pmatrix}$$ - .. code-block:: text + the given `axes` is: $[1, 0]$, and $Y$ = transpose($X$, axis) - input = numpy.arange(6).reshape((2,3)) + then the output $Y$ is: - the input is: + $$ + Y = \begin{pmatrix} + 0 &3 \\ + 1 &4 \\ + 2 &5 + \end{pmatrix}$$ - array([[0, 1, 2], - [3, 4, 5]]) - - given axis is: - - [1, 0] - - output = input.transpose(axis) - - then the output is: - - array([[0, 3], - [1, 4], - [2, 5]]) - -So, given a input tensor of shape(N, C, H, W) and the axis is {0, 2, 3, 1}, -the output tensor shape will be (N, H, W, C) +- Given a input tensor with shape $(N, C, H, W)$ and the `axes` is +$[0, 2, 3, 1]$, then shape of the output tensor will be: $(N, H, W, C)$. )DOC"); } -- GitLab