Skip to content

Commit

Permalink
Update nadaraya-waston.md
Browse files Browse the repository at this point in the history
Line660: Add ".detach()" into origin code in order to adapt the torch 2.0
  • Loading branch information
Machillka authored Feb 23, 2024
1 parent e6b18cc commit 40f8a45
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions chapter_attention-mechanisms/nadaraya-waston.md
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ d2l.show_heatmaps(np.expand_dims(

```{.python .input}
#@tab pytorch
d2l.show_heatmaps(net.attention_weights.unsqueeze(0).unsqueeze(0),
d2l.show_heatmaps(net.attention_weights.detach().unsqueeze(0).unsqueeze(0),
xlabel='Sorted training inputs',
ylabel='Sorted testing inputs')
```
Expand Down Expand Up @@ -700,4 +700,4 @@ d2l.show_heatmaps(net.attention_weight.unsqueeze(0).unsqueeze(0),

:begin_tab:`paddle`
[Discussions](https://discuss.d2l.ai/t/11840)
:end_tab:
:end_tab:

0 comments on commit 40f8a45

Please sign in to comment.