Skip to content

Commit cdf4967

Browse files
eric-haibin-lingyshi
authored andcommitted
[DOC] Fix doc for nn.Embedding, nn.Dense and nd.Embedding (apache#15869)
* Update basic_layers.py * Update indexing_op.cc
1 parent e72465c commit cdf4967

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

python/mxnet/gluon/nn/basic_layers.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,9 @@ class Dense(HybridBlock):
151151
created by the layer, and `bias` is a bias vector created by the layer
152152
(only applicable if `use_bias` is `True`).
153153
154-
Note: the input must be a tensor with rank 2. Use `flatten` to convert it
155-
to rank 2 manually if necessary.
154+
.. note::
155+
the input must be a tensor with rank 2. Use `flatten` to convert it
156+
to rank 2 manually if necessary.
156157
157158
Parameters
158159
----------
@@ -379,11 +380,13 @@ class Embedding(HybridBlock):
379380
r"""Turns non-negative integers (indexes/tokens) into dense vectors
380381
of fixed size. eg. [4, 20] -> [[0.25, 0.1], [0.6, -0.2]]
381382
382-
Note: if `sparse_grad` is set to True, the gradient w.r.t weight will be
383-
sparse. Only a subset of optimizers support sparse gradients, including SGD, AdaGrad
384-
and Adam. By default lazy updates is turned on, which may perform differently
385-
from standard updates. For more details, please check the Optimization API at:
386-
https://mxnet.incubator.apache.org/api/python/optimization/optimization.html
383+
.. note::
384+
if `sparse_grad` is set to True, the gradient w.r.t weight will be
385+
sparse. Only a subset of optimizers support sparse gradients, including SGD,
386+
AdaGrad and Adam. By default lazy updates is turned on, which may perform
387+
differently from standard updates. For more details, please check the
388+
Optimization API at:
389+
https://mxnet.incubator.apache.org/api/python/optimization/optimization.html
387390
388391
Parameters
389392
----------

src/operator/tensor/indexing_op.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,8 +490,9 @@ All the input values should be integers in the range [0, input_dim).
490490
If the input_dim is ip0 and output_dim is op0, then shape of the embedding weight matrix must be
491491
(ip0, op0).
492492
493-
By default, if any index mentioned is too large, it is replaced by the index that addresses
494-
the last vector in an embedding matrix.
493+
When "sparse_grad" is False, if any index mentioned is too large, it is replaced by the index that
494+
addresses the last vector in an embedding matrix.
495+
When "sparse_grad" is True, an error will be raised if invalid indices are found.
495496
496497
Examples::
497498

0 commit comments

Comments
 (0)