Skip to content

Commit 23aebf0

Browse files
committed
update softmax layer comment
1 parent e7d8e16 commit 23aebf0

File tree

1 file changed

+10
-7
lines changed
  • python/paddle/fluid/layers

1 file changed

+10
-7
lines changed

python/paddle/fluid/layers/nn.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,21 +1313,24 @@ def sequence_softmax(input, param_attr=None, bias_attr=None, use_cudnn=True):
13131313

13141314
def softmax(input, param_attr=None, bias_attr=None, use_cudnn=True, name=None):
13151315
"""
1316-
The input of the softmax layer is a 2-D tensor with shape N x K (N is the
1317-
batch_size, K is the dimension of input feature). The output tensor has the
1318-
same shape as the input tensor.
1316+
The input of the softmax operator is a tensor of any rank. The output tensor
1317+
has the same shape as the input.
13191318
1320-
For each row of the input tensor, the softmax operator squashes the
1321-
K-dimensional vector of arbitrary real values to a K-dimensional vector of real
1322-
values in the range [0, 1] that add up to 1.
1319+
The input tensor will first be logically flattened to a 2-D matrix. The matrix's
1320+
second dimension(row length) is as same as the last dimension of the input
1321+
tensor, and the first dimension(column length) is the product of all other
1322+
dimensions of the input tensor. For each row of the matrix, the softmax operator
1323+
squashes the K-dimensional(K is the width of the matrix, which is also the size
1324+
of the input tensor's last dimension) vector of arbitrary real values to a
1325+
K-dimensional vector of real values in the range [0, 1] that add up to 1.
13231326
13241327
It computes the exponential of the given dimension and the sum of exponential
13251328
values of all the other dimensions in the K-dimensional vector input.
13261329
Then the ratio of the exponential of the given dimension and the sum of
13271330
exponential values of all the other dimensions is the output of the softmax
13281331
operator.
13291332
1330-
For each row :math:`i` and each column :math:`j` in Input(X), we have:
1333+
For each row :math:`i` and each column :math:`j` in the matrix, we have:
13311334
13321335
.. math::
13331336

0 commit comments

Comments
 (0)