Skip to content

Commit

Permalink
Fixing documentation for torchtext nn modules (#1267)
Browse files Browse the repository at this point in the history
  • Loading branch information
parmeet authored Apr 1, 2021
1 parent eb5e39d commit 93b03e4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/source/nn_modules.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
.. role:: hidden
:class: hidden-section

torchtext.nn.modules.multiheadattention
torchtext.nn
=======================================

.. automodule:: torchtext.nn.modules.multiheadattention
.. currentmodule:: torchtext.nn.modules.multiheadattention
.. automodule:: torchtext.nn
.. currentmodule:: torchtext.nn

:hidden:`MultiheadAttentionContainer`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
3 changes: 3 additions & 0 deletions torchtext/nn/modules/multiheadattention.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def __init__(self, nhead, in_proj_container, attention_layer, out_proj, batch_fi
Examples::
>>> import torch
>>> from torchtext.nn import MultiheadAttentionContainer, InProjContainer, ScaledDotProduct
>>> embed_dim, num_heads, bsz = 10, 5, 64
>>> in_proj_container = InProjContainer(torch.nn.Linear(embed_dim, embed_dim),
torch.nn.Linear(embed_dim, embed_dim),
Expand Down Expand Up @@ -122,6 +123,7 @@ def __init__(self, dropout=0.0, batch_first=False):
as `(batch, seq, feature)`. Default: ``False``
Examples::
>>> import torch, torchtext
>>> SDP = torchtext.nn.ScaledDotProduct(dropout=0.1)
>>> q = torch.randn(21, 256, 3)
>>> k = v = torch.randn(21, 256, 3)
Expand Down Expand Up @@ -245,6 +247,7 @@ def forward(self,
value (Tensor): The values to be projected.
Examples::
>>> import torch
>>> from torchtext.nn import InProjContainer
>>> embed_dim, bsz = 10, 64
>>> in_proj_container = InProjContainer(torch.nn.Linear(embed_dim, embed_dim),
Expand Down

0 comments on commit 93b03e4

Please sign in to comment.