Skip to content

Commit

Permalink
Fix the loss initialization in intermediate_source/char_rnn_generatio…
Browse files Browse the repository at this point in the history
…n_tutorial.py (#2380)

* changed the loss init to make it less confusing
---------

Co-authored-by: Nicolas Hug <contact@nicolas-hug.com>
Co-authored-by: Svetlana Karslioglu <svekars@fb.com>
  • Loading branch information
3 people authored Jun 2, 2023
1 parent b966c1f commit 769cff9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion intermediate_source/char_rnn_generation_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def train(category_tensor, input_line_tensor, target_line_tensor):

rnn.zero_grad()

loss = 0
loss = torch.Tensor([0]) # you can also just simply use ``loss = 0``

for i in range(input_line_tensor.size(0)):
output, hidden = rnn(category_tensor, input_line_tensor[i], hidden)
Expand Down

0 comments on commit 769cff9

Please sign in to comment.