From 9eaceb889aeb1ba822210fa9611ac3033190b5d3 Mon Sep 17 00:00:00 2001
From: Y-yyyyq <648203301@qq.com>
Date: Sun, 7 Dec 2025 16:39:42 +0800
Subject: [PATCH 01/20] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=93=E6=9E=9C?=
=?UTF-8?q?=E8=BE=93=E5=87=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../0_attention-cues.ipynb | 798 ++++++++++++++++--
1 file changed, 750 insertions(+), 48 deletions(-)
diff --git a/chapter_10_attention_mechanisms/0_attention-cues.ipynb b/chapter_10_attention_mechanisms/0_attention-cues.ipynb
index 0e6adeb..b6f379b 100644
--- a/chapter_10_attention_mechanisms/0_attention-cues.ipynb
+++ b/chapter_10_attention_mechanisms/0_attention-cues.ipynb
@@ -2,32 +2,32 @@
"cells": [
{
"cell_type": "markdown",
+ "metadata": {},
"source": [
"# Attention Cue"
- ],
- "metadata": {
- "collapsed": false
- }
+ ]
},
{
"cell_type": "code",
- "execution_count": null,
- "outputs": [],
- "source": [
- "import sys\n",
- "sys.path.append('..')"
- ],
+ "execution_count": 1,
"metadata": {
"collapsed": false,
+ "jupyter": {
+ "outputs_hidden": false
+ },
"pycharm": {
"name": "#%%\n"
}
- }
+ },
+ "outputs": [],
+ "source": [
+ "import sys\n",
+ "sys.path.append('..')"
+ ]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true,
"pycharm": {
"name": "#%% md\n"
}
@@ -38,30 +38,40 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "outputs": [],
- "source": [
- "from d2l import mindspore as d2l"
- ],
+ "execution_count": 3,
"metadata": {
"collapsed": false,
+ "jupyter": {
+ "outputs_hidden": false
+ },
"pycharm": {
"name": "#%%\n"
}
- }
+ },
+ "outputs": [],
+ "source": [
+ "from d2l import mindspore as d2l"
+ ]
},
{
"cell_type": "markdown",
+ "metadata": {},
"source": [
"为了可视化注意力权重,需要定义一个`show_heatmaps`函数。"
- ],
- "metadata": {
- "collapsed": false
- }
+ ]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false,
+ "jupyter": {
+ "outputs_hidden": false
+ },
+ "pycharm": {
+ "name": "#%%\n"
+ }
+ },
"outputs": [],
"source": [
"#@save\n",
@@ -82,58 +92,750 @@
" if titles:\n",
" ax.set_title(titles[j])\n",
" fig.colorbar(pcm, ax=axes, shrink=0.6);"
- ],
- "metadata": {
- "collapsed": false,
- "pycharm": {
- "name": "#%%\n"
- }
- }
+ ]
},
{
"cell_type": "markdown",
+ "metadata": {},
"source": [
"下面使用一个简单的例子进行演示"
- ],
- "metadata": {
- "collapsed": false
- }
+ ]
},
{
"cell_type": "code",
- "execution_count": null,
- "outputs": [],
- "source": [
- "attention_weights = d2l.eye(10).reshape((1, 1, 10, 10))\n",
- "show_heatmaps(attention_weights, xlabel='Keys', ylabel='Queries')"
- ],
+ "execution_count": 5,
"metadata": {
"collapsed": false,
+ "jupyter": {
+ "outputs_hidden": false
+ },
"pycharm": {
"name": "#%%\n"
}
- }
+ },
+ "outputs": [
+ {
+ "data": {
+ "image/svg+xml": [
+ "\n",
+ "\n",
+ "\n"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "attention_weights = d2l.eye(10).reshape((1, 1, 10, 10))\n",
+ "show_heatmaps(attention_weights, xlabel='Keys', ylabel='Queries')"
+ ]
}
],
"metadata": {
"kernelspec": {
- "display_name": "Python 3",
+ "display_name": "Python 3.10",
"language": "python",
- "name": "python3"
+ "name": "py310"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
- "version": 2
+ "version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
- "pygments_lexer": "ipython2",
- "version": "2.7.6"
+ "pygments_lexer": "ipython3",
+ "version": "3.10.14"
}
},
"nbformat": 4,
- "nbformat_minor": 0
-}
\ No newline at end of file
+ "nbformat_minor": 4
+}
From 42b9b8e757b2939b69419b104033ac3317666dbf Mon Sep 17 00:00:00 2001
From: Y-yyyyq <648203301@qq.com>
Date: Sun, 7 Dec 2025 16:40:58 +0800
Subject: [PATCH 02/20] Remove empty code cell in adadelta.ipynb
---
chapter_11_optimization/adadelta.ipynb | 8 --------
1 file changed, 8 deletions(-)
diff --git a/chapter_11_optimization/adadelta.ipynb b/chapter_11_optimization/adadelta.ipynb
index d190699..a72f92b 100644
--- a/chapter_11_optimization/adadelta.ipynb
+++ b/chapter_11_optimization/adadelta.ipynb
@@ -1429,14 +1429,6 @@
"trainer = mindspore.nn.Adadelta\n",
"d2l.train_concise_ch11(trainer, {'rho': 0.9}, data_iter)"
]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9ec4ddb9",
- "metadata": {},
- "outputs": [],
- "source": []
}
],
"metadata": {
From ad9499ad27dd3d3bdf9b853a2ea9c0ec83a35c32 Mon Sep 17 00:00:00 2001
From: Y-yyyyq <648203301@qq.com>
Date: Sun, 7 Dec 2025 16:41:28 +0800
Subject: [PATCH 03/20] Remove empty code cell from adagrad.ipynb
---
chapter_11_optimization/adagrad.ipynb | 8 --------
1 file changed, 8 deletions(-)
diff --git a/chapter_11_optimization/adagrad.ipynb b/chapter_11_optimization/adagrad.ipynb
index d0ad4d2..17a4424 100644
--- a/chapter_11_optimization/adagrad.ipynb
+++ b/chapter_11_optimization/adagrad.ipynb
@@ -3254,14 +3254,6 @@
"trainer = mindspore.nn.Adagrad\n",
"d2l.train_concise_ch11(trainer, {'learning_rate': 0.1}, data_iter)"
]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2e2b346e",
- "metadata": {},
- "outputs": [],
- "source": []
}
],
"metadata": {
From b14770223a210f82ec7201647f92443a1f68cf25 Mon Sep 17 00:00:00 2001
From: Y-yyyyq <648203301@qq.com>
Date: Sun, 7 Dec 2025 16:42:02 +0800
Subject: [PATCH 04/20] Remove empty code cell from adam.ipynb
---
chapter_11_optimization/adam.ipynb | 8 --------
1 file changed, 8 deletions(-)
diff --git a/chapter_11_optimization/adam.ipynb b/chapter_11_optimization/adam.ipynb
index a78aa17..4927931 100644
--- a/chapter_11_optimization/adam.ipynb
+++ b/chapter_11_optimization/adam.ipynb
@@ -2138,14 +2138,6 @@
"d2l.train_ch11(yogi, init_adam_states(feature_dim),\n",
" {'lr': 0.01, 't': 1}, data_iter, feature_dim);"
]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "0a611fda",
- "metadata": {},
- "outputs": [],
- "source": []
}
],
"metadata": {
From 19cbaa960d4cce2466bde7a17c33d8c95b30cab6 Mon Sep 17 00:00:00 2001
From: Y-yyyyq <648203301@qq.com>
Date: Sun, 7 Dec 2025 16:42:28 +0800
Subject: [PATCH 05/20] Remove empty code cell from convexity.ipynb
---
chapter_11_optimization/convexity.ipynb | 8 --------
1 file changed, 8 deletions(-)
diff --git a/chapter_11_optimization/convexity.ipynb b/chapter_11_optimization/convexity.ipynb
index c42b401..d1b4afa 100644
--- a/chapter_11_optimization/convexity.ipynb
+++ b/chapter_11_optimization/convexity.ipynb
@@ -1602,14 +1602,6 @@
"d2l.set_figsize()\n",
"d2l.plot([x, segment], [f(x), f(segment)], 'x', 'f(x)')"
]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "eb71705e",
- "metadata": {},
- "outputs": [],
- "source": []
}
],
"metadata": {
From df259f133b1a7150472181362f67aeff098ba8a4 Mon Sep 17 00:00:00 2001
From: Y-yyyyq <648203301@qq.com>
Date: Sun, 7 Dec 2025 16:43:05 +0800
Subject: [PATCH 06/20] Update gd.ipynb
---
chapter_11_optimization/gd.ipynb | 8 --------
1 file changed, 8 deletions(-)
diff --git a/chapter_11_optimization/gd.ipynb b/chapter_11_optimization/gd.ipynb
index 27f4a57..ed814ea 100644
--- a/chapter_11_optimization/gd.ipynb
+++ b/chapter_11_optimization/gd.ipynb
@@ -5274,14 +5274,6 @@
"source": [
"show_trace(newton(0.5), f)"
]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "28611729",
- "metadata": {},
- "outputs": [],
- "source": []
}
],
"metadata": {
From df2e1255e20b3dd2bac6b7167f646126e66ac559 Mon Sep 17 00:00:00 2001
From: Y-yyyyq <648203301@qq.com>
Date: Sun, 7 Dec 2025 16:43:35 +0800
Subject: [PATCH 07/20] Remove empty code cell from lr-scheduler.ipynb
---
chapter_11_optimization/lr-scheduler.ipynb | 8 --------
1 file changed, 8 deletions(-)
diff --git a/chapter_11_optimization/lr-scheduler.ipynb b/chapter_11_optimization/lr-scheduler.ipynb
index 397fb76..41cad68 100644
--- a/chapter_11_optimization/lr-scheduler.ipynb
+++ b/chapter_11_optimization/lr-scheduler.ipynb
@@ -5719,14 +5719,6 @@
"trainer = nn.SGD(net.trainable_params(), lr_list)\n",
"train(net, train_iter, test_iter, num_epochs, loss, trainer)"
]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7fa1a852",
- "metadata": {},
- "outputs": [],
- "source": []
}
],
"metadata": {
From 86c10d6f3866c13ca6194bba5d215b621431e5c4 Mon Sep 17 00:00:00 2001
From: Y-yyyyq <648203301@qq.com>
Date: Sun, 7 Dec 2025 16:44:10 +0800
Subject: [PATCH 08/20] Remove empty code cell from minibatch-sgd.ipynb
---
chapter_11_optimization/minibatch-sgd.ipynb | 8 --------
1 file changed, 8 deletions(-)
diff --git a/chapter_11_optimization/minibatch-sgd.ipynb b/chapter_11_optimization/minibatch-sgd.ipynb
index 2b0e62f..dba542f 100644
--- a/chapter_11_optimization/minibatch-sgd.ipynb
+++ b/chapter_11_optimization/minibatch-sgd.ipynb
@@ -5038,14 +5038,6 @@
"trainer = nn.SGD\n",
"train_concise_ch11(trainer, {'learning_rate': 0.01}, data_iter)"
]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "abc4fa58",
- "metadata": {},
- "outputs": [],
- "source": []
}
],
"metadata": {
From 0b30cb288425b75401bcae8d99b51b4a2e815a7e Mon Sep 17 00:00:00 2001
From: Y-yyyyq <648203301@qq.com>
Date: Sun, 7 Dec 2025 16:44:43 +0800
Subject: [PATCH 09/20] Remove empty code cell from momentum.ipynb
---
chapter_11_optimization/momentum.ipynb | 8 --------
1 file changed, 8 deletions(-)
diff --git a/chapter_11_optimization/momentum.ipynb b/chapter_11_optimization/momentum.ipynb
index 9b6650f..3373291 100644
--- a/chapter_11_optimization/momentum.ipynb
+++ b/chapter_11_optimization/momentum.ipynb
@@ -8225,14 +8225,6 @@
"d2l.plt.xlabel('time')\n",
"d2l.plt.legend();"
]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "d5850a00",
- "metadata": {},
- "outputs": [],
- "source": []
}
],
"metadata": {
From e14a569a8151b7664efec187cc805ed93f151ca0 Mon Sep 17 00:00:00 2001
From: Y-yyyyq <648203301@qq.com>
Date: Sun, 7 Dec 2025 16:45:08 +0800
Subject: [PATCH 10/20] Remove empty code cell from optimization-intro.ipynb
---
chapter_11_optimization/optimization-intro.ipynb | 8 --------
1 file changed, 8 deletions(-)
diff --git a/chapter_11_optimization/optimization-intro.ipynb b/chapter_11_optimization/optimization-intro.ipynb
index 82a0224..ce841a5 100644
--- a/chapter_11_optimization/optimization-intro.ipynb
+++ b/chapter_11_optimization/optimization-intro.ipynb
@@ -6190,14 +6190,6 @@
"d2l.plot(x, [d2l.tanh(x)], 'x', 'f(x)')\n",
"annotate('vanishing gradient', (4, 1), (2, 0.0))"
]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9c531836",
- "metadata": {},
- "outputs": [],
- "source": []
}
],
"metadata": {
From fef707aeadcb9be72fcb1bd8b076bae6d9c6de79 Mon Sep 17 00:00:00 2001
From: Y-yyyyq <648203301@qq.com>
Date: Sun, 7 Dec 2025 16:45:33 +0800
Subject: [PATCH 11/20] Remove empty code cell in rmsprop.ipynb
---
chapter_11_optimization/rmsprop.ipynb | 8 --------
1 file changed, 8 deletions(-)
diff --git a/chapter_11_optimization/rmsprop.ipynb b/chapter_11_optimization/rmsprop.ipynb
index eeb4dfa..4320ffa 100644
--- a/chapter_11_optimization/rmsprop.ipynb
+++ b/chapter_11_optimization/rmsprop.ipynb
@@ -2996,14 +2996,6 @@
"d2l.train_concise_ch11(trainer, {'learning_rate': 0.01, 'decay': 0.9},\n",
" data_iter)"
]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "b2676f86",
- "metadata": {},
- "outputs": [],
- "source": []
}
],
"metadata": {
From e9509d7cdf3a2188f652ca647c63617158a0f128 Mon Sep 17 00:00:00 2001
From: Y-yyyyq <648203301@qq.com>
Date: Sun, 7 Dec 2025 16:46:06 +0800
Subject: [PATCH 12/20] Update sgd.ipynb
---
chapter_11_optimization/sgd.ipynb | 8 --------
1 file changed, 8 deletions(-)
diff --git a/chapter_11_optimization/sgd.ipynb b/chapter_11_optimization/sgd.ipynb
index 634a296..e3ac6e5 100644
--- a/chapter_11_optimization/sgd.ipynb
+++ b/chapter_11_optimization/sgd.ipynb
@@ -3377,14 +3377,6 @@
"lr = polynomial_lr\n",
"d2l.show_trace_2d(f, d2l.train_2d(sgd, steps=50, f_grad=f_grad))"
]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "b8ee2734",
- "metadata": {},
- "outputs": [],
- "source": []
}
],
"metadata": {
From d965c7a23528dfd6756803d357ad3443b838ff5d Mon Sep 17 00:00:00 2001
From: Y-yyyyq <648203301@qq.com>
Date: Mon, 8 Dec 2025 18:00:49 +0800
Subject: [PATCH 13/20] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dmindspore2.7.1=E5=85=BC?=
=?UTF-8?q?=E5=AE=B9=E6=80=A7=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../3_multihead-attention.ipynb | 61 +++++++++++--------
1 file changed, 37 insertions(+), 24 deletions(-)
diff --git a/chapter_10_attention_mechanisms/3_multihead-attention.ipynb b/chapter_10_attention_mechanisms/3_multihead-attention.ipynb
index fa017ac..0a161d0 100644
--- a/chapter_10_attention_mechanisms/3_multihead-attention.ipynb
+++ b/chapter_10_attention_mechanisms/3_multihead-attention.ipynb
@@ -24,7 +24,7 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": null,
"metadata": {
"origin_pos": 2,
"tab": [
@@ -35,7 +35,8 @@
"source": [
"from d2l import mindspore as d2l\n",
"import mindspore\n",
- "from mindspore import nn"
+ "from mindspore import nn\n",
+ "import mindspore.mint as mint"
]
},
{
@@ -71,24 +72,28 @@
" self.W_k = nn.Dense(key_size, num_hiddens, has_bias=has_bias)\n",
" self.W_v = nn.Dense(value_size, num_hiddens, has_bias=has_bias)\n",
" self.W_o = nn.Dense(num_hiddens, num_hiddens, has_bias=has_bias)\n",
+ " # mint 中没有 expand_dims,保留 tile 和 reshape\n",
+ " self.tile = mint.tile \n",
+ " self.reshape = mint.reshape\n",
+ " # 移除 self.expand_dims = mint.expand_dims,将在 construct 中使用 Tensor 方法\n",
"\n",
" def construct(self, queries, keys, values, valid_lens):\n",
" # queries,keys,values的形状:\n",
" # (batch_size,查询或者“键-值”对的个数,num_hiddens)\n",
- " # valid_lens 的形状:\n",
- " # (batch_size,)或(batch_size,查询的个数)\n",
- " # 经过变换后,输出的queries,keys,values 的形状:\n",
- " # (batch_size*num_heads,查询或者“键-值”对的个数,\n",
- " # num_hiddens/num_heads)\n",
" queries = transpose_qkv(self.W_q(queries), self.num_heads)\n",
" keys = transpose_qkv(self.W_k(keys), self.num_heads)\n",
" values = transpose_qkv(self.W_v(values), self.num_heads)\n",
"\n",
" if valid_lens is not None:\n",
- " # 在轴0,将第一项(标量或者矢量)复制num_heads次,\n",
- " # 然后如此复制第二项,然后诸如此类。\n",
- " valid_lens = d2l.repeat(\n",
- " valid_lens, repeats=self.num_heads, axis=0)\n",
+ " \n",
+ " # 1. 扩展 valid_lens 形状至 (batch_size, 1)\n",
+ " valid_lens = valid_lens.expand_dims(1)\n",
+ " \n",
+ " # 2. 沿着轴 1 (新增维度) 重复 num_heads 次,形状变为 (batch_size, num_heads)\n",
+ " valid_lens = self.tile(valid_lens, (1, self.num_heads))\n",
+ " \n",
+ " # 3. 展平为 (batch_size * num_heads,)\n",
+ " valid_lens = self.reshape(valid_lens, (-1,))\n",
"\n",
" # output的形状:(batch_size*num_heads,查询的个数,\n",
" # num_hiddens/num_heads)\n",
@@ -167,18 +172,26 @@
]
},
"outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "[WARNING] ME(42683:281472939304512,MainProcess):2025-12-08-17:59:06.972.000 [mindspore/nn/layer/basic.py:174] For Dropout, this parameter `keep_prob` will be deprecated, please use `p` instead.\n",
+ "[WARNING] ME(42683:281472939304512,MainProcess):2025-12-08-17:59:06.984.000 [mindspore/nn/layer/basic.py:200] For Dropout, this parameter `keep_prob` will be deprecated, please use `p` instead.\n"
+ ]
+ },
{
"data": {
"text/plain": [
- "MultiHeadAttention<\n",
- " (attention): DotProductAttention<\n",
- " (dropout): Dropout\n",
- " >\n",
- " (W_q): Dense\n",
- " (W_k): Dense\n",
- " (W_v): Dense\n",
- " (W_o): Dense\n",
- " >"
+ "MultiHeadAttention(\n",
+ " (attention): DotProductAttention(\n",
+ " (dropout): Dropout(keep_prob=0.5)\n",
+ " )\n",
+ " (W_q): Dense(input_channels=100, output_channels=100)\n",
+ " (W_k): Dense(input_channels=100, output_channels=100)\n",
+ " (W_v): Dense(input_channels=100, output_channels=100)\n",
+ " (W_o): Dense(input_channels=100, output_channels=100)\n",
+ ")"
]
},
"execution_count": 5,
@@ -226,9 +239,9 @@
"metadata": {
"celltoolbar": "Slideshow",
"kernelspec": {
- "display_name": "Python 3 (ipykernel)",
+ "display_name": "Python 3.10",
"language": "python",
- "name": "python3"
+ "name": "py310"
},
"language_info": {
"codemirror_mode": {
@@ -240,7 +253,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.7.5"
+ "version": "3.10.14"
},
"rise": {
"autolaunch": true,
@@ -251,4 +264,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
-}
\ No newline at end of file
+}
From 0daa530313edf57a49fd10885459378c1f3d697a Mon Sep 17 00:00:00 2001
From: Y-yyyyq <648203301@qq.com>
Date: Mon, 8 Dec 2025 18:13:29 +0800
Subject: [PATCH 14/20] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dmindspore2.7.1=E5=85=BC?=
=?UTF-8?q?=E5=AE=B9=E6=80=A7=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
...lf-attention-and-positional-encoding.ipynb | 1402 ++++++++---------
1 file changed, 692 insertions(+), 710 deletions(-)
diff --git a/chapter_10_attention_mechanisms/4_self-attention-and-positional-encoding.ipynb b/chapter_10_attention_mechanisms/4_self-attention-and-positional-encoding.ipynb
index d526128..c6e7a69 100644
--- a/chapter_10_attention_mechanisms/4_self-attention-and-positional-encoding.ipynb
+++ b/chapter_10_attention_mechanisms/4_self-attention-and-positional-encoding.ipynb
@@ -24,7 +24,7 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": null,
"metadata": {
"origin_pos": 2,
"tab": [
@@ -35,7 +35,21 @@
"source": [
"from d2l import mindspore as d2l\n",
"import mindspore\n",
- "from mindspore import nn"
+ "from mindspore import nn\n",
+ "\n",
+ "def repeat(x, repeats, axis=0):\n",
+ " # 针对 d2l 中 valid_lens 的场景 (输入通常是 1D 张量)\n",
+ " if len(x.shape) == 1:\n",
+ " # 1. 升维:(Batch,) -> (Batch, 1)\n",
+ " x = x.reshape((-1, 1))\n",
+ " # 2. 平铺:在第1维复制 repeats 次 -> (Batch, repeats)\n",
+ " x = x.tile((1, repeats))\n",
+ " # 3. 展平:按行展开 -> (Batch * repeats, )\n",
+ " return x.reshape((-1,))\n",
+ " \n",
+ " return x.tile((repeats,)) \n",
+ "\n",
+ "d2l.repeat = repeat"
]
},
{
@@ -59,18 +73,26 @@
]
},
"outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "[WARNING] ME(45659:281473853007424,MainProcess):2025-12-08-18:07:47.223.000 [mindspore/nn/layer/basic.py:174] For Dropout, this parameter `keep_prob` will be deprecated, please use `p` instead.\n",
+ "[WARNING] ME(45659:281473853007424,MainProcess):2025-12-08-18:07:47.235.000 [mindspore/nn/layer/basic.py:200] For Dropout, this parameter `keep_prob` will be deprecated, please use `p` instead.\n"
+ ]
+ },
{
"data": {
"text/plain": [
- "MultiHeadAttention<\n",
- " (attention): DotProductAttention<\n",
- " (dropout): Dropout\n",
- " >\n",
- " (W_q): Dense\n",
- " (W_k): Dense\n",
- " (W_v): Dense\n",
- " (W_o): Dense\n",
- " >"
+ "MultiHeadAttention(\n",
+ " (attention): DotProductAttention(\n",
+ " (dropout): Dropout(keep_prob=0.5)\n",
+ " )\n",
+ " (W_q): Dense(input_channels=100, output_channels=100)\n",
+ " (W_k): Dense(input_channels=100, output_channels=100)\n",
+ " (W_v): Dense(input_channels=100, output_channels=100)\n",
+ " (W_o): Dense(input_channels=100, output_channels=100)\n",
+ ")"
]
},
"execution_count": 3,
@@ -177,10 +199,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
- "[WARNING] KERNEL(882468,7eff72988740,python):2021-11-24-12:17:57.010.249 [mindspore/ccsrc/backend/kernel_compiler/gpu/gpu_kernel_factory.cc:96] ReducePrecision] Kernel [TensorScatterUpdate] does not support int64, cast input 1 to int32.\n",
- "[WARNING] PRE_ACT(882468,7eff72988740,python):2021-11-24-12:17:57.010.406 [mindspore/ccsrc/backend/optimizer/gpu/reduce_precision_fusion.cc:83] Run] Reduce precision for [TensorScatterUpdate] input 1\n",
- "[WARNING] KERNEL(882468,7eff72988740,python):2021-11-24-12:17:57.022.569 [mindspore/ccsrc/backend/kernel_compiler/gpu/gpu_kernel_factory.cc:96] ReducePrecision] Kernel [TensorScatterUpdate] does not support int64, cast input 1 to int32.\n",
- "[WARNING] PRE_ACT(882468,7eff72988740,python):2021-11-24-12:17:57.022.689 [mindspore/ccsrc/backend/optimizer/gpu/reduce_precision_fusion.cc:83] Run] Reduce precision for [TensorScatterUpdate] input 1\n"
+ "[WARNING] ME(45659:281473853007424,MainProcess):2025-12-08-18:08:00.342.000 [mindspore/nn/layer/basic.py:174] For Dropout, this parameter `keep_prob` will be deprecated, please use `p` instead.\n"
]
},
{
@@ -189,64 +208,64 @@
"\n",
"\n",
- "