Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
book
提交
31662047
B
book
项目概览
PaddlePaddle
/
book
通知
16
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
40
列表
看板
标记
里程碑
合并请求
37
Wiki
5
Wiki
分析
仓库
DevOps
项目成员
Pages
B
book
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
40
Issue
40
列表
看板
标记
里程碑
合并请求
37
合并请求
37
Pages
分析
分析
仓库分析
DevOps
Wiki
5
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
31662047
编写于
9月 10, 2020
作者:
J
jzhang533
提交者:
GitHub
9月 10, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update several notebooks (#894)
上级
5ab525db
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
297 addition
and
314 deletion
+297
-314
paddle2.0_docs/convnet_image_classification/convnet_image_classification.ipynb
...t_image_classification/convnet_image_classification.ipynb
+46
-48
paddle2.0_docs/dynamic_graph/dynamic_graph.ipynb
paddle2.0_docs/dynamic_graph/dynamic_graph.ipynb
+49
-51
paddle2.0_docs/hello_paddle/hello_paddle.ipynb
paddle2.0_docs/hello_paddle/hello_paddle.ipynb
+23
-23
paddle2.0_docs/image_search/image_search.ipynb
paddle2.0_docs/image_search/image_search.ipynb
+66
-70
paddle2.0_docs/imdb_bow_classification/imdb_bow_classification.ipynb
...ocs/imdb_bow_classification/imdb_bow_classification.ipynb
+32
-31
paddle2.0_docs/seq2seq_with_attention/seq2seq_with_attention.ipynb
..._docs/seq2seq_with_attention/seq2seq_with_attention.ipynb
+81
-91
未找到文件。
paddle2.0_docs/convnet_image_classification/convnet_image_classification.ipynb
浏览文件 @
31662047
此差异已折叠。
点击以展开。
paddle2.0_docs/dynamic_graph/dynamic_graph.ipynb
浏览文件 @
31662047
...
@@ -29,8 +29,7 @@
...
@@ -29,8 +29,7 @@
"name": "stdout",
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"0.0.0\n",
"2.0.0-beta0\n"
"89af2088b6e74bdfeef2d4d78e08461ed2aafee5\n"
]
]
}
}
],
],
...
@@ -40,8 +39,7 @@
...
@@ -40,8 +39,7 @@
"import numpy as np\n",
"import numpy as np\n",
"\n",
"\n",
"paddle.disable_static()\n",
"paddle.disable_static()\n",
"print(paddle.__version__)\n",
"print(paddle.__version__)"
"print(paddle.__git_commit__)\n"
]
]
},
},
{
{
...
@@ -62,16 +60,16 @@
...
@@ -62,16 +60,16 @@
"name": "stdout",
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"[[
-0.49341336 -0.8112665
]\n",
"[[
1.5645729 -0.74514765
]\n",
" [
0.8929015 0.24661176
]\n",
" [
-0.01248 0.68240154
]\n",
" [
-0.64440054 -0.7945008
]\n",
" [
0.11316949 -1.6579045
]\n",
" [-0.
07345356 1.3641853
]]\n",
" [-0.
1425675 -1.0153968
]]\n",
"[1. 2.]\n",
"[1. 2.]\n",
"[[
0.5065867 1.1887336
]\n",
"[[
2.5645728 1.2548523
]\n",
" [
1.8929014 2.2466118
]\n",
" [
0.98752 2.6824017
]\n",
" [
0.35559946 1.2054992
]\n",
" [
1.1131694 0.3420955
]\n",
" [0.
92654645 3.3641853
]]\n",
" [0.
8574325 0.98460317
]]\n",
"[
-2.1159463 1.386125 -2.2334023 2.654917
]\n"
"[
0.07427764 1.352323 -3.2026396 -2.173361
]\n"
]
]
}
}
],
],
...
@@ -100,7 +98,7 @@
...
@@ -100,7 +98,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
4
,
"execution_count":
5
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
...
@@ -108,12 +106,12 @@
...
@@ -108,12 +106,12 @@
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"0 +> [5 6 7]\n",
"0 +> [5 6 7]\n",
"1
+> [5 7 9
]\n",
"1
-> [-3 -3 -3
]\n",
"2 +> [ 5 9 15]\n",
"2 +> [ 5 9 15]\n",
"3 -> [-3 3 21]\n",
"3 -> [-3 3 21]\n",
"4
-> [-3 11 75
]\n",
"4
+> [ 5 21 87
]\n",
"5
+> [ 5 37 249
]\n",
"5
-> [ -3 27 237
]\n",
"6
+> [ 5 69 735
]\n",
"6
-> [ -3 59 723
]\n",
"7 -> [ -3 123 2181]\n",
"7 -> [ -3 123 2181]\n",
"8 +> [ 5 261 6567]\n",
"8 +> [ 5 261 6567]\n",
"9 +> [ 5 517 19689]\n"
"9 +> [ 5 517 19689]\n"
...
@@ -146,7 +144,7 @@
...
@@ -146,7 +144,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
5
,
"execution_count":
6
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -172,28 +170,28 @@
...
@@ -172,28 +170,28 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
5
,
"execution_count":
7
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"name": "stdout",
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"0 [
2.0915627
]\n",
"0 [
1.3384138
]\n",
"200 [0.
67530334
]\n",
"200 [0.
7855983
]\n",
"400 [0.5
2042854
]\n",
"400 [0.5
9084535
]\n",
"600 [0.
28010666
]\n",
"600 [0.
30849028
]\n",
"800 [0.
09739777
]\n",
"800 [0.
26992702
]\n",
"1000 [0.0
9307177
]\n",
"1000 [0.0
3990713
]\n",
"1200 [0.0
4252927
]\n",
"1200 [0.0
7111286
]\n",
"1400 [0.0
3095707
]\n",
"1400 [0.0
1177792
]\n",
"1600 [0.03
022156
]\n",
"1600 [0.03
160322
]\n",
"1800 [0.0
1616007
]\n",
"1800 [0.0
2757282
]\n",
"2000 [0.0
1069116
]\n",
"2000 [0.0
0916022
]\n",
"2200 [0.00
55158
]\n",
"2200 [0.00
217024
]\n",
"2400 [0.001
95092
]\n",
"2400 [0.001
86833
]\n",
"2600 [0.00101
11
6]\n",
"2600 [0.00101
92
6]\n",
"2800 [0.00
192219
]\n"
"2800 [0.00
09654
]\n"
]
]
}
}
],
],
...
@@ -220,8 +218,8 @@
...
@@ -220,8 +218,8 @@
" print(t, loss.numpy())\n",
" print(t, loss.numpy())\n",
"\n",
"\n",
" loss.backward()\n",
" loss.backward()\n",
" optimizer.
minimize(loss
)\n",
" optimizer.
step(
)\n",
"
model.clear_gradients
()"
"
optimizer.clear_grad
()"
]
]
},
},
{
{
...
@@ -230,29 +228,29 @@
...
@@ -230,29 +228,29 @@
"source": [
"source": [
"# 构建更加灵活的网络:共享权重\n",
"# 构建更加灵活的网络:共享权重\n",
"\n",
"\n",
"- 使用动态图还可以更加方便的创建共享权重的网络,下面的示例展示了一个共享了权重的简单的AutoEncoder
的示例
。\n",
"- 使用动态图还可以更加方便的创建共享权重的网络,下面的示例展示了一个共享了权重的简单的AutoEncoder。\n",
"- 你也可以参考图像搜索的示例看到共享参数权重的更实际的使用。"
"- 你也可以参考图像搜索的示例看到共享参数权重的更实际的使用。"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
7
,
"execution_count":
8
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"name": "stdout",
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"step: 0, loss: [0.3
7666085
]\n",
"step: 0, loss: [0.3
3474904
]\n",
"step: 1, loss: [0.3
06384
5]\n",
"step: 1, loss: [0.3
166951
5]\n",
"step: 2, loss: [0.2
64724
8]\n",
"step: 2, loss: [0.2
972968
8]\n",
"step: 3, loss: [0.2
3831272
]\n",
"step: 3, loss: [0.2
7288628
]\n",
"step: 4, loss: [0.2
1714918
]\n",
"step: 4, loss: [0.2
4694422
]\n",
"step: 5, loss: [0.
1955545
]\n",
"step: 5, loss: [0.
2203041
]\n",
"step: 6, loss: [0.1
7261818
]\n",
"step: 6, loss: [0.1
9171436
]\n",
"step: 7, loss: [0.1
5009595
]\n",
"step: 7, loss: [0.1
6213782
]\n",
"step: 8, loss: [0.13
051331
]\n",
"step: 8, loss: [0.13
443354
]\n",
"step: 9, loss: [0.11
537809
]\n"
"step: 9, loss: [0.11
170781
]\n"
]
]
}
}
],
],
...
@@ -270,8 +268,8 @@
...
@@ -270,8 +268,8 @@
" loss = loss_fn(outputs, inputs)\n",
" loss = loss_fn(outputs, inputs)\n",
" loss.backward()\n",
" loss.backward()\n",
" print(\"step: {}, loss: {}\".format(i, loss.numpy()))\n",
" print(\"step: {}, loss: {}\".format(i, loss.numpy()))\n",
" optimizer.
minimize(loss
)\n",
" optimizer.
step(
)\n",
"
linear.clear_gradients
()"
"
optimizer.clear_grad
()"
]
]
},
},
{
{
...
...
paddle2.0_docs/hello_paddle/hello_paddle.ipynb
浏览文件 @
31662047
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 2
4
,
"execution_count": 2
2
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
...
@@ -90,21 +90,21 @@
...
@@ -90,21 +90,21 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
25
,
"execution_count":
3
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"name": "stdout",
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"paddle
version 0.0.
0\n"
"paddle
2.0.0-beta
0\n"
]
]
}
}
],
],
"source": [
"source": [
"import paddle\n",
"import paddle\n",
"paddle.disable_static()\n",
"paddle.disable_static()\n",
"print(\"paddle
version
\" + paddle.__version__)"
"print(\"paddle \" + paddle.__version__)"
]
]
},
},
{
{
...
@@ -121,7 +121,7 @@
...
@@ -121,7 +121,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
26
,
"execution_count":
4
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -150,7 +150,7 @@
...
@@ -150,7 +150,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
27
,
"execution_count":
5
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -168,14 +168,14 @@
...
@@ -168,14 +168,14 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
28
,
"execution_count":
6
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"name": "stdout",
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"w before optimize: -1.
7107375860214233
\n",
"w before optimize: -1.
696260690689087
\n",
"b before optimize: 0.0\n"
"b before optimize: 0.0\n"
]
]
}
}
...
@@ -205,7 +205,7 @@
...
@@ -205,7 +205,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
29
,
"execution_count":
7
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -224,19 +224,19 @@
...
@@ -224,19 +224,19 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
30
,
"execution_count":
8
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"name": "stdout",
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"epoch 0 loss [2
107.3943
]\n",
"epoch 0 loss [2
094.069
]\n",
"epoch 1000 loss [7.84
32994
]\n",
"epoch 1000 loss [7.84
51133
]\n",
"epoch 2000 loss [1.75
37074
]\n",
"epoch 2000 loss [1.75
41145
]\n",
"epoch 3000 loss [0.392
11753
]\n",
"epoch 3000 loss [0.392
21546
]\n",
"epoch 4000 loss [0.0876
7726
]\n",
"epoch 4000 loss [0.0876
9739
]\n",
"finished training, loss [0.01963
376
]\n"
"finished training, loss [0.01963
82
]\n"
]
]
}
}
],
],
...
@@ -246,8 +246,8 @@
...
@@ -246,8 +246,8 @@
" y_predict = linear(x_data)\n",
" y_predict = linear(x_data)\n",
" loss = mse_loss(y_predict, y_data)\n",
" loss = mse_loss(y_predict, y_data)\n",
" loss.backward()\n",
" loss.backward()\n",
" sgd_optimizer.
minimize(loss
)\n",
" sgd_optimizer.
step(
)\n",
"
linear.clear_gradients
()\n",
"
sgd_optimizer.clear_grad
()\n",
" \n",
" \n",
" if i%1000 == 0:\n",
" if i%1000 == 0:\n",
" print(\"epoch {} loss {}\".format(i, loss.numpy()))\n",
" print(\"epoch {} loss {}\".format(i, loss.numpy()))\n",
...
@@ -266,15 +266,15 @@
...
@@ -266,15 +266,15 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
31
,
"execution_count":
9
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"name": "stdout",
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"w after optimize: 2.01784
3246459961
\n",
"w after optimize: 2.01784
51538085938
\n",
"b after optimize: 9.7718
51539611816
\n"
"b after optimize: 9.7718
25790405273
\n"
]
]
}
}
],
],
...
@@ -297,7 +297,7 @@
...
@@ -297,7 +297,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
32
,
"execution_count":
10
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
...
@@ -339,5 +339,5 @@
...
@@ -339,5 +339,5 @@
}
}
},
},
"nbformat": 4,
"nbformat": 4,
"nbformat_minor":
1
"nbformat_minor":
4
}
}
paddle2.0_docs/image_search/image_search.ipynb
浏览文件 @
31662047
此差异已折叠。
点击以展开。
paddle2.0_docs/imdb_bow_classification/imdb_bow_classification.ipynb
浏览文件 @
31662047
...
@@ -9,9 +9,7 @@
...
@@ -9,9 +9,7 @@
"本示例教程演示如何在IMDB数据集上用简单的BOW网络完成文本分类的任务。\n",
"本示例教程演示如何在IMDB数据集上用简单的BOW网络完成文本分类的任务。\n",
"\n",
"\n",
"IMDB数据集是一个对电影评论标注为正向评论与负向评论的数据集,共有25000条文本数据作为训练集,25000条文本数据作为测试集。\n",
"IMDB数据集是一个对电影评论标注为正向评论与负向评论的数据集,共有25000条文本数据作为训练集,25000条文本数据作为测试集。\n",
"该数据集的官方地址为: http://ai.stanford.edu/~amaas/data/sentiment/\n",
"该数据集的官方地址为: http://ai.stanford.edu/~amaas/data/sentiment/"
"\n",
"- Warning: `paddle.dataset.imdb`先在是一个非常粗野的实现,后续需要有替代的方案。"
]
]
},
},
{
{
...
@@ -25,15 +23,14 @@
...
@@ -25,15 +23,14 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
4
,
"execution_count":
2
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"name": "stdout",
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"0.0.0\n",
"2.0.0-beta0\n"
"264e76cae6861ad9b1d4bcd8c3212f7a78c01e4d\n"
]
]
}
}
],
],
...
@@ -42,8 +39,7 @@
...
@@ -42,8 +39,7 @@
"import numpy as np\n",
"import numpy as np\n",
"\n",
"\n",
"paddle.disable_static()\n",
"paddle.disable_static()\n",
"print(paddle.__version__)\n",
"print(paddle.__version__)"
"print(paddle.__git_commit__)\n"
]
]
},
},
{
{
...
@@ -57,7 +53,7 @@
...
@@ -57,7 +53,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
5
,
"execution_count":
3
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
...
@@ -78,7 +74,7 @@
...
@@ -78,7 +74,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
6
,
"execution_count":
4
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
...
@@ -126,7 +122,7 @@
...
@@ -126,7 +122,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
7
,
"execution_count":
22
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -157,7 +153,7 @@
...
@@ -157,7 +153,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
8
,
"execution_count":
23
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
...
@@ -190,7 +186,7 @@
...
@@ -190,7 +186,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
9
,
"execution_count":
24
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
...
@@ -241,7 +237,7 @@
...
@@ -241,7 +237,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
11
,
"execution_count":
25
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -269,19 +265,19 @@
...
@@ -269,19 +265,19 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
13
,
"execution_count":
26
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"name": "stdout",
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"epoch: 0, batch_id: 0, loss is: [0.69
26701
]\n",
"epoch: 0, batch_id: 0, loss is: [0.69
18494
]\n",
"epoch: 0, batch_id: 500, loss is: [0.
41248566
]\n",
"epoch: 0, batch_id: 500, loss is: [0.
33142853
]\n",
"[validation] accuracy/loss: 0.850
5121469497681/0.3615057170391083
\n",
"[validation] accuracy/loss: 0.850
6321907043457/0.3620821535587311
\n",
"epoch: 1, batch_id: 0, loss is: [0.
29521096
]\n",
"epoch: 1, batch_id: 0, loss is: [0.
37161
]\n",
"epoch: 1, batch_id: 500, loss is: [0.2
916747
]\n",
"epoch: 1, batch_id: 500, loss is: [0.2
296829
]\n",
"[validation] accuracy/loss: 0.86
475670337677/0.3259459137916565
\n"
"[validation] accuracy/loss: 0.86
22759580612183/0.3286365270614624
\n"
]
]
}
}
],
],
...
@@ -311,8 +307,8 @@
...
@@ -311,8 +307,8 @@
" if batch_id % 500 == 0:\n",
" if batch_id % 500 == 0:\n",
" print(\"epoch: {}, batch_id: {}, loss is: {}\".format(epoch, batch_id, avg_loss.numpy()))\n",
" print(\"epoch: {}, batch_id: {}, loss is: {}\".format(epoch, batch_id, avg_loss.numpy()))\n",
" avg_loss.backward()\n",
" avg_loss.backward()\n",
" opt.
minimize(avg_loss
)\n",
" opt.
step(
)\n",
"
model.clear_gradients
()\n",
"
opt.clear_grad
()\n",
"\n",
"\n",
" # evaluate model after one epoch\n",
" # evaluate model after one epoch\n",
" model.eval()\n",
" model.eval()\n",
...
@@ -349,13 +345,6 @@
...
@@ -349,13 +345,6 @@
"\n",
"\n",
"可以看到,在这个数据集上,经过两轮的迭代可以得到86%左右的准确率。你也可以通过调整网络结构和超参数,来获得更好的效果。"
"可以看到,在这个数据集上,经过两轮的迭代可以得到86%左右的准确率。你也可以通过调整网络结构和超参数,来获得更好的效果。"
]
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
}
],
],
"metadata": {
"metadata": {
...
@@ -369,8 +358,20 @@
...
@@ -369,8 +358,20 @@
"display_name": "Python 3",
"display_name": "Python 3",
"language": "python",
"language": "python",
"name": "python3"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.7"
}
}
},
},
"nbformat": 4,
"nbformat": 4,
"nbformat_minor":
1
"nbformat_minor":
4
}
}
paddle2.0_docs/seq2seq_with_attention/seq2seq_with_attention.ipynb
浏览文件 @
31662047
...
@@ -27,8 +27,7 @@
...
@@ -27,8 +27,7 @@
"name": "stdout",
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"0.0.0\n",
"2.0.0-beta0\n"
"89af2088b6e74bdfeef2d4d78e08461ed2aafee5\n"
]
]
}
}
],
],
...
@@ -39,8 +38,7 @@
...
@@ -39,8 +38,7 @@
"import numpy as np\n",
"import numpy as np\n",
"\n",
"\n",
"paddle.disable_static()\n",
"paddle.disable_static()\n",
"print(paddle.__version__)\n",
"print(paddle.__version__)"
"print(paddle.__git_commit__)"
]
]
},
},
{
{
...
@@ -61,16 +59,16 @@
...
@@ -61,16 +59,16 @@
"name": "stdout",
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"--2020-09-
04 16:13:3
5-- https://www.manythings.org/anki/cmn-eng.zip\n",
"--2020-09-
10 16:17:2
5-- https://www.manythings.org/anki/cmn-eng.zip\n",
"Resolving www.manythings.org (www.manythings.org)...
104.24.109.196, 172.67.173.198
, 2606:4700:3037::6818:6cc4, ...\n",
"Resolving www.manythings.org (www.manythings.org)...
2606:4700:3033::6818:6dc4, 2606:4700:3036::ac43:adc6
, 2606:4700:3037::6818:6cc4, ...\n",
"Connecting to www.manythings.org (www.manythings.org)|
104.24.109.196
|:443... connected.\n",
"Connecting to www.manythings.org (www.manythings.org)|
2606:4700:3033::6818:6dc4
|:443... connected.\n",
"HTTP request sent, awaiting response... 200 OK\n",
"HTTP request sent, awaiting response... 200 OK\n",
"Length: 1030722 (1007K) [application/zip]\n",
"Length: 1030722 (1007K) [application/zip]\n",
"Saving to: ‘cmn-eng.zip’\n",
"Saving to: ‘cmn-eng.zip’\n",
"\n",
"\n",
"cmn-eng.zip 100%[===================>] 1007K
520KB/s in 1.9s
\n",
"cmn-eng.zip 100%[===================>] 1007K
91.2KB/s in 11s
\n",
"\n",
"\n",
"2020-09-
04 16:13:38 (520
KB/s) - ‘cmn-eng.zip’ saved [1030722/1030722]\n",
"2020-09-
10 16:17:38 (91.2
KB/s) - ‘cmn-eng.zip’ saved [1030722/1030722]\n",
"\n",
"\n",
"Archive: cmn-eng.zip\n",
"Archive: cmn-eng.zip\n",
" inflating: cmn.txt \n",
" inflating: cmn.txt \n",
...
@@ -91,7 +89,7 @@
...
@@ -91,7 +89,7 @@
"name": "stdout",
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
" 23610 cmn.txt\
r\
n"
" 23610 cmn.txt\n"
]
]
}
}
],
],
...
@@ -421,65 +419,65 @@
...
@@ -421,65 +419,65 @@
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"epoch:0\n",
"epoch:0\n",
"iter 0, loss:[7.6
194725
]\n",
"iter 0, loss:[7.6
20109
]\n",
"iter 200, loss:[
3.4147663
]\n",
"iter 200, loss:[
2.9760551
]\n",
"epoch:1\n",
"epoch:1\n",
"iter 0, loss:[
3.093165
6]\n",
"iter 0, loss:[
2.967959
6]\n",
"iter 200, loss:[
2.7543137
]\n",
"iter 200, loss:[
3.161064
]\n",
"epoch:2\n",
"epoch:2\n",
"iter 0, loss:[2.
8413522
]\n",
"iter 0, loss:[2.
7516625
]\n",
"iter 200, loss:[2.
34051
3]\n",
"iter 200, loss:[2.
975542
3]\n",
"epoch:3\n",
"epoch:3\n",
"iter 0, loss:[2.
597812
]\n",
"iter 0, loss:[2.
7249248
]\n",
"iter 200, loss:[2.
5552855
]\n",
"iter 200, loss:[2.
3419888
]\n",
"epoch:4\n",
"epoch:4\n",
"iter 0, loss:[2.
0783448
]\n",
"iter 0, loss:[2.
3236473
]\n",
"iter 200, loss:[2.
4544785
]\n",
"iter 200, loss:[2.
3453429
]\n",
"epoch:5\n",
"epoch:5\n",
"iter 0, loss:[
1.870913
5]\n",
"iter 0, loss:[
2.192697
5]\n",
"iter 200, loss:[
1.8736631
]\n",
"iter 200, loss:[
2.1977856
]\n",
"epoch:6\n",
"epoch:6\n",
"iter 0, loss:[
1.9589291
]\n",
"iter 0, loss:[
2.014393
]\n",
"iter 200, loss:[2.1
19414
]\n",
"iter 200, loss:[2.1
863418
]\n",
"epoch:7\n",
"epoch:7\n",
"iter 0, loss:[1.
5829577
]\n",
"iter 0, loss:[1.
8619595
]\n",
"iter 200, loss:[1.
6002902
]\n",
"iter 200, loss:[1.
8904227
]\n",
"epoch:8\n",
"epoch:8\n",
"iter 0, loss:[1.
6022769
]\n",
"iter 0, loss:[1.
5901132
]\n",
"iter 200, loss:[1.
52694
]\n",
"iter 200, loss:[1.
7812968
]\n",
"epoch:9\n",
"epoch:9\n",
"iter 0, loss:[1.3
61668
5]\n",
"iter 0, loss:[1.3
4156
5]\n",
"iter 200, loss:[1.
5420443
]\n",
"iter 200, loss:[1.
4957166
]\n",
"epoch:10\n",
"epoch:10\n",
"iter 0, loss:[1.
0397792
]\n",
"iter 0, loss:[1.
2202356
]\n",
"iter 200, loss:[1.
245823
1]\n",
"iter 200, loss:[1.
348534
1]\n",
"epoch:11\n",
"epoch:11\n",
"iter 0, loss:[1.
2107158
]\n",
"iter 0, loss:[1.
1035374
]\n",
"iter 200, loss:[1.
426417
]\n",
"iter 200, loss:[1.
2871654
]\n",
"epoch:12\n",
"epoch:12\n",
"iter 0, loss:[1.1
840894
]\n",
"iter 0, loss:[1.1
94801
]\n",
"iter 200, loss:[1.0
99966
4]\n",
"iter 200, loss:[1.0
47995
4]\n",
"epoch:13\n",
"epoch:13\n",
"iter 0, loss:[1.0
968472
]\n",
"iter 0, loss:[1.0
022258
]\n",
"iter 200, loss:[
0.8149167
]\n",
"iter 200, loss:[
1.0899843
]\n",
"epoch:14\n",
"epoch:14\n",
"iter 0, loss:[0.9
5585203
]\n",
"iter 0, loss:[0.9
3466896
]\n",
"iter 200, loss:[
1.0070628
]\n",
"iter 200, loss:[
0.99347967
]\n",
"epoch:15\n",
"epoch:15\n",
"iter 0, loss:[0.8
9463925
]\n",
"iter 0, loss:[0.8
3665943
]\n",
"iter 200, loss:[0.
8288595
]\n",
"iter 200, loss:[0.
9594004
]\n",
"epoch:16\n",
"epoch:16\n",
"iter 0, loss:[0.
5672495
]\n",
"iter 0, loss:[0.
78929776
]\n",
"iter 200, loss:[0.
73170
69]\n",
"iter 200, loss:[0.
9457
69]\n",
"epoch:17\n",
"epoch:17\n",
"iter 0, loss:[0.
76785177
]\n",
"iter 0, loss:[0.
62574965
]\n",
"iter 200, loss:[0.
531932
3]\n",
"iter 200, loss:[0.
630816
3]\n",
"epoch:18\n",
"epoch:18\n",
"iter 0, loss:[0.
5250005
]\n",
"iter 0, loss:[0.
63433456
]\n",
"iter 200, loss:[0.
4182841
]\n",
"iter 200, loss:[0.
6287957
]\n",
"epoch:19\n",
"epoch:19\n",
"iter 0, loss:[0.5
2320284
]\n",
"iter 0, loss:[0.5
4270047
]\n",
"iter 200, loss:[0.
47618982
]\n"
"iter 200, loss:[0.
72688276
]\n"
]
]
}
}
],
],
...
@@ -527,9 +525,8 @@
...
@@ -527,9 +525,8 @@
" print(\"iter {}, loss:{}\".format(iteration, loss.numpy()))\n",
" print(\"iter {}, loss:{}\".format(iteration, loss.numpy()))\n",
"\n",
"\n",
" loss.backward()\n",
" loss.backward()\n",
" opt.minimize(loss)\n",
" opt.step()\n",
" encoder.clear_gradients()\n",
" opt.clear_grad()"
" atten_decoder.clear_gradients()"
]
]
},
},
{
{
...
@@ -544,43 +541,43 @@
...
@@ -544,43 +541,43 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 1
8
,
"execution_count": 1
2
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"name": "stdout",
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"i
agree with him
\n",
"i
want to study french
\n",
"true: 我
同意他
。\n",
"true: 我
要学法语
。\n",
"pred: 我
同意他
。\n",
"pred: 我
要学法语
。\n",
"i
think i ll take a bath tonight
\n",
"i
didn t know that he was there
\n",
"true: 我
想我今晚會洗澡
。\n",
"true: 我
不知道他在那裡
。\n",
"pred: 我
想我今晚會洗澡
。\n",
"pred: 我
不知道他在那裡
。\n",
"
he asked for a drink of water
\n",
"
i called tom
\n",
"true:
他要了水喝
。\n",
"true:
我給湯姆打了電話
。\n",
"pred:
他喝了一杯水
。\n",
"pred:
我看見湯姆了
。\n",
"
i began running
\n",
"
he is getting along with his employees
\n",
"true:
我開始跑
。\n",
"true:
他和他的員工相處
。\n",
"pred:
我開始跑
。\n",
"pred:
他和他的員工相處
。\n",
"
i m sick
\n",
"
we raced toward the fire
\n",
"true: 我
生病了
。\n",
"true: 我
們急忙跑向火
。\n",
"pred: 我
生病了
。\n",
"pred: 我
們住在美國
。\n",
"
you had better go to the dentist s
\n",
"
i ran away in a hurry
\n",
"true:
你最好去看牙醫
。\n",
"true:
我趕快跑走了
。\n",
"pred:
你最好去看牙醫
。\n",
"pred:
我在班里是最高
。\n",
"
we went for a walk in the forest
\n",
"
he cut the envelope open
\n",
"true:
我们去了林中散步
。\n",
"true:
他裁開了那個信封
。\n",
"pred:
我們去公园散步
。\n",
"pred:
他裁開了信封
。\n",
"
you ve arrived very early
\n",
"
he s shorter than tom
\n",
"true:
你來得很早
。\n",
"true:
他比湯姆矮
。\n",
"pred:
你去早个
。\n",
"pred:
他比湯姆矮
。\n",
"
he pretended not to be listening
\n",
"
i ve just started playing tennis
\n",
"true:
他裝作沒在聽
。\n",
"true:
我剛開始打網球
。\n",
"pred:
他假装聽到它
。\n",
"pred:
我剛去打網球
。\n",
"
he always wanted to study japanes
e\n",
"
i need to go hom
e\n",
"true:
他一直想學日語
。\n",
"true:
我该回家了
。\n",
"pred:
他一直想學日語
。\n"
"pred:
我该回家了
。\n"
]
]
}
}
],
],
...
@@ -632,13 +629,6 @@
...
@@ -632,13 +629,6 @@
"\n",
"\n",
"你还可以通过变换网络结构,调整数据集,尝试不同的参数的方式来进一步提升本示例当中的机器翻译的效果。同时,也可以尝试在其他的类似的任务中用飞桨来完成实际的实践。"
"你还可以通过变换网络结构,调整数据集,尝试不同的参数的方式来进一步提升本示例当中的机器翻译的效果。同时,也可以尝试在其他的类似的任务中用飞桨来完成实际的实践。"
]
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
}
],
],
"metadata": {
"metadata": {
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录