@@ -43,18 +43,18 @@ def softmax(
43
43
r"""
44
44
This operator implements the compat.softmax. The calculation process is as follows:
45
45
46
- 1. The dimension :attr:`axis ` of ``x `` will be permuted to the last.
46
+ 1. The dimension :attr:`dim ` of ``input `` will be permuted to the last.
47
47
48
- 2. Then ``x `` will be logically flattened to a 2-D matrix. The matrix's second
49
- dimension(row length) is the same as the dimension :attr:`axis` of ``x ``,
48
+ 2. Then ``input `` will be logically flattened to a 2-D matrix. The matrix's second
49
+ dimension(row length) is the same as the dimension :attr:`axis` of ``input ``,
50
50
and the first dimension(column length) is the product of all other dimensions
51
- of ``x ``. For each row of the matrix, the softmax operator squashes the
52
- K-dimensional(K is the width of the matrix, which is also the size of ``x ``'s
53
- dimension :attr:`axis `) vector of arbitrary real values to a K-dimensional
51
+ of ``input ``. For each row of the matrix, the softmax operator squashes the
52
+ K-dimensional(K is the width of the matrix, which is also the size of ``input ``'s
53
+ dimension :attr:`dim `) vector of arbitrary real values to a K-dimensional
54
54
vector of real values in the range [0, 1] that add up to 1.
55
55
56
56
3. After the softmax operation is completed, the inverse operations of steps 1 and 2
57
- are performed to restore the two-dimensional matrix to the same dimension as the ``x `` .
57
+ are performed to restore the two-dimensional matrix to the same dimension as the ``input `` .
58
58
59
59
It computes the exponential of the given dimension and the sum of exponential
60
60
values of all the other dimensions in the K-dimensional vector input.
@@ -66,24 +66,24 @@ def softmax(
66
66
67
67
.. math::
68
68
69
- softmax[i, j] = \frac{\exp(x [i, j])}{\sum_j(exp(x [i, j])}
69
+ softmax[i, j] = \frac{\exp(input [i, j])}{\sum_j(exp(input [i, j])}
70
70
71
71
Example:
72
72
73
73
.. code-block:: text
74
74
75
75
Case 1:
76
76
Input:
77
- x .shape = [2, 3, 4]
78
- x .data = [[[2.0, 3.0, 4.0, 5.0],
77
+ input .shape = [2, 3, 4]
78
+ input .data = [[[2.0, 3.0, 4.0, 5.0],
79
79
[3.0, 4.0, 5.0, 6.0],
80
80
[7.0, 8.0, 8.0, 9.0]],
81
81
[[1.0, 2.0, 3.0, 4.0],
82
82
[5.0, 6.0, 7.0, 8.0],
83
83
[6.0, 7.0, 8.0, 9.0]]]
84
84
85
85
Attrs:
86
- axis = -1
86
+ dim = -1
87
87
88
88
Output:
89
89
out.shape = [2, 3, 4]
@@ -96,15 +96,15 @@ def softmax(
96
96
97
97
Case 2:
98
98
Input:
99
- x .shape = [2, 3, 4]
100
- x .data = [[[2.0, 3.0, 4.0, 5.0],
99
+ input .shape = [2, 3, 4]
100
+ input .data = [[[2.0, 3.0, 4.0, 5.0],
101
101
[3.0, 4.0, 5.0, 6.0],
102
102
[7.0, 8.0, 8.0, 9.0]],
103
103
[[1.0, 2.0, 3.0, 4.0],
104
104
[5.0, 6.0, 7.0, 8.0],
105
105
[6.0, 7.0, 8.0, 9.0]]]
106
106
Attrs:
107
- axis = 1
107
+ dim = 1
108
108
109
109
Output:
110
110
out.shape = [2, 3, 4]
@@ -117,16 +117,16 @@ def softmax(
117
117
118
118
Parameters:
119
119
input (Tensor): The input Tensor with data type bfloat16, float16, float32, float64.
120
- dim (int, optional): The axis along which to perform softmax
120
+ dim (int, optional): The dim along which to perform softmax
121
121
calculations. It should be in range [-D, D), where D is the
122
- rank of ``x `` . If ``axis `` < 0, it works the same way as
123
- :math:`axis + D` . Default is None.
122
+ rank of ``input `` . If ``dim `` < 0, it works the same way as
123
+ :math:`dim + D` . Default is None.
124
124
dtype (str, optional): The data type of the output tensor, can be bfloat16, float16, float32, float64.
125
125
out (Tensor, optional): The output Tensor.
126
126
127
127
Returns:
128
128
A Tensor with the same shape and data type (use ``dtype`` if it is
129
- specified) as x .
129
+ specified) as input .
130
130
131
131
Examples:
132
132
.. code-block:: python
0 commit comments