From 40f8a4510ee500bd06daab935b2a870927c38f74 Mon Sep 17 00:00:00 2001 From: Machillka <84647953+Machillka@users.noreply.github.com> Date: Fri, 23 Feb 2024 04:00:36 -0500 Subject: [PATCH] Update nadaraya-waston.md Line660: Add ".detach()" into origin code in order to adapt the torch 2.0 --- chapter_attention-mechanisms/nadaraya-waston.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chapter_attention-mechanisms/nadaraya-waston.md b/chapter_attention-mechanisms/nadaraya-waston.md index 5417ea8c5..290c2a063 100644 --- a/chapter_attention-mechanisms/nadaraya-waston.md +++ b/chapter_attention-mechanisms/nadaraya-waston.md @@ -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') ``` @@ -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: \ No newline at end of file +:end_tab: