Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6b3af99

Browse files
mabdullahsoyturkSvetlana Karslioglu
andauthored
fix "some elements of the input tensor and the written-to tensor refer to a single memory location" error in ddp_pipeline tutorial (#2002)
Co-authored-by: Svetlana Karslioglu <[email protected]>
1 parent 5880829 commit 6b3af99

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

advanced_source/ddp_pipeline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def __init__(self, d_model, dropout=0.1, max_len=5000):
5252
pe[:, 0::2] = torch.sin(position * div_term)
5353
pe[:, 1::2] = torch.cos(position * div_term)
5454
pe = pe.unsqueeze(0).transpose(0, 1)
55-
self.register_buffer('pe', pe)
55+
self.pe = nn.Parameter(pe, requires_grad=False)
5656

5757
def forward(self, x):
5858
x = x + self.pe[:x.size(0), :]

0 commit comments

Comments
 (0)