Skip to content

Commit

Permalink
update practises of 2.3.0 version (#4735)
Browse files Browse the repository at this point in the history
* update practises of 2.3.0 version

* modify hello_paddle

* update practises of 2.3.0 version
  • Loading branch information
yang131313 authored May 11, 2022
1 parent 86f6e30 commit ec652b0
Show file tree
Hide file tree
Showing 24 changed files with 1,810 additions and 1,876 deletions.
88 changes: 44 additions & 44 deletions docs/practices/cv/convnet_image_classification.ipynb

Large diffs are not rendered by default.

104 changes: 43 additions & 61 deletions docs/practices/cv/image_classification.ipynb
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"# 使用LeNet在MNIST数据集实现图像分类\n",
"\n",
"**作者:** [PaddlePaddle](https://github.com/PaddlePaddle) <br>\n",
"**日期:** 2022.4 <br>\n",
"**日期:** 2022.5 <br>\n",
"**摘要:** 本示例教程演示如何在MNIST数据集上用LeNet进行图像分类。"
]
},
Expand All @@ -21,12 +21,12 @@
"source": [
"## 一、环境配置\n",
"\n",
"本教程基于PaddlePaddle 2.3.0-rc0 编写,如果你的环境不是本版本,请先参考官网[安装](https://www.paddlepaddle.org.cn/install/quick) PaddlePaddle 2.3.0-rc0"
"本教程基于PaddlePaddle 2.3.0 编写,如果你的环境不是本版本,请先参考官网[安装](https://www.paddlepaddle.org.cn/install/quick) PaddlePaddle 2.3.0。"
]
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {
"collapsed": false
},
Expand All @@ -35,7 +35,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"2.3.0-rc0\n"
"2.3.0\n"
]
}
],
Expand All @@ -58,7 +58,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {
"collapsed": false
},
Expand Down Expand Up @@ -87,7 +87,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {
"collapsed": false
},
Expand All @@ -98,6 +98,16 @@
"text": [
"train_data0 label is: [5]\n"
]
},
{
"data": {
"image/png": "iVBORw0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R65OGRcI0my58pfAXztnPtL2qGCapH88OFDlXt7e1XetWuXyjdv3sz6XP6PJt23b5/KdXV1KhfCdaJMglyQXAJgC4D/iEi3t+9PSBbQP712yf0AfpufIVIhCPKq7QqAwTpBsUUyAeCVbTIyYu61PXnyRGX/x2R1d3er7G/lN1xLlixJbfv/1n/NmjUqjx8/PqdzFQLOSGSChUQmWEhkoqDWSNeuXUttHzlyRB3zvy96YGAgp3NNmDBBZf/Ht6ffH/N/PHsx4oxEJlhIZKKgntpaW1vfuR2E/0981q1bp3IikVC5oaFBZX93f9I4I5EJFhKZYCGRCba1oSGxrQ2FioVEJlhIZIKFRCZYSGSChUQmWEhkgoVEJlhIZIKFRCZYSGQi1HttIvIYyb/KLQPwQ2gnHp64ji2qcc10zmVs2hBqIaVOKtIZ5EZgFOI6triO6y0+tZEJFhKZiKqQPonovEHEdWxxHReAiNZINPLwqY1MhFpIIrJWRPpE5LaIRNpOWUROicgjEelJ2xeL3uGF2Ns8tEISkQSAEwB+A6AawEavX3dUmgGs9e2LS+/wwutt7pwL5QvALwG0peVGAI1hnX+QMVUB6EnLfQDKve1yAH1Rji9tXJ8CWBXX8TnnQn1qqwDwXVoe8PbFSex6hxdKb3Mutgfhkv/tI31Jm21v8yiEWUjfA6hMy+97++IkUO/wMOTS2zwKYRZSB4A5IvKBiJQAqEeyV3ecvO0dDkTYOzxAb3Mgbr3NQ140fgjgGwB3AByIeAHbguSH9bxGcr32EYCfIvlq6BaASwBKIxrbr5B82roBoNv7+jAu43vXF69skwkutskEC4lMsJDIBAuJTLCQyAQLiUywkMgEC4lM/A+jN2A4bkW+2gAAAABJRU5ErkJggg==\n",
"text/plain": [
"<Figure size 144x144 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
Expand All @@ -122,7 +132,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {
"collapsed": false
},
Expand Down Expand Up @@ -178,20 +188,11 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"W0422 18:56:10.020583 19533 gpu_context.cc:244] Please NOTE: device: 0, GPU Compute Capability: 7.0, Driver API Version: 10.1, Runtime API Version: 10.1\n",
"W0422 18:56:10.026566 19533 gpu_context.cc:272] device: 0, cuDNN Version: 7.6.\n"
]
}
],
"outputs": [],
"source": [
"from paddle.metric import Accuracy\n",
"model = paddle.Model(LeNet()) # 用Model封装模型\n",
Expand All @@ -207,30 +208,11 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The loss value printed in the log is the current step, and the metric is the average value of previous steps.\n",
"Epoch 1/2\n",
"step 20/938 [..............................] - loss: 1.4646 - acc: 0.3828 - ETA: 17s - 19ms/ste"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"step 30/938 [..............................] - loss: 1.1068 - acc: 0.4672 - ETA: 14s - 16ms/stepstep 938/938 [==============================] - loss: 0.1653 - acc: 0.9273 - 11ms/step \n",
"Epoch 2/2\n",
"step 938/938 [==============================] - loss: 0.0199 - acc: 0.9767 - 11ms/step \n"
]
}
],
"outputs": [],
"source": [
"# 训练模型\n",
"model.fit(train_dataset,\n",
Expand All @@ -251,7 +233,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {
"collapsed": false
},
Expand All @@ -261,17 +243,17 @@
"output_type": "stream",
"text": [
"Eval begin...\n",
"step 157/157 [==============================] - loss: 0.0048 - acc: 0.9780 - 8ms/step \n",
"step 157/157 [==============================] - loss: 4.2854e-04 - acc: 0.9841 - 7ms/step \n",
"Eval samples: 10000\n"
]
},
{
"data": {
"text/plain": [
"{'loss': [0.0047780997], 'acc': 0.978}"
"{'loss': [0.00042853763], 'acc': 0.9841}"
]
},
"execution_count": 7,
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -303,7 +285,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {
"collapsed": false
},
Expand All @@ -312,14 +294,14 @@
"name": "stdout",
"output_type": "stream",
"text": [
"epoch: 0, batch_id: 0, loss is: [3.7514806], acc is: [0.21875]\n",
"epoch: 0, batch_id: 300, loss is: [0.19029362], acc is: [0.953125]\n",
"epoch: 0, batch_id: 600, loss is: [0.12201739], acc is: [0.953125]\n",
"epoch: 0, batch_id: 900, loss is: [0.03218058], acc is: [0.984375]\n",
"epoch: 1, batch_id: 0, loss is: [0.114471], acc is: [0.953125]\n",
"epoch: 1, batch_id: 300, loss is: [0.00857661], acc is: [1.]\n",
"epoch: 1, batch_id: 600, loss is: [0.10740176], acc is: [0.96875]\n",
"epoch: 1, batch_id: 900, loss is: [0.19590104], acc is: [0.9375]\n"
"epoch: 0, batch_id: 0, loss is: [2.9878871], acc is: [0.140625]\n",
"epoch: 0, batch_id: 300, loss is: [0.22775462], acc is: [0.921875]\n",
"epoch: 0, batch_id: 600, loss is: [0.06251755], acc is: [0.984375]\n",
"epoch: 0, batch_id: 900, loss is: [0.1097075], acc is: [0.96875]\n",
"epoch: 1, batch_id: 0, loss is: [0.04311676], acc is: [0.984375]\n",
"epoch: 1, batch_id: 300, loss is: [0.00150577], acc is: [1.]\n",
"epoch: 1, batch_id: 600, loss is: [0.08764459], acc is: [0.96875]\n",
"epoch: 1, batch_id: 900, loss is: [0.14419323], acc is: [0.9375]\n"
]
}
],
Expand Down Expand Up @@ -361,7 +343,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {
"collapsed": false
},
Expand All @@ -370,14 +352,14 @@
"name": "stdout",
"output_type": "stream",
"text": [
"batch_id: 0, loss is: [0.04440754], acc is: [0.984375]\n",
"batch_id: 20, loss is: [0.19196557], acc is: [0.9375]\n",
"batch_id: 40, loss is: [0.09817676], acc is: [0.984375]\n",
"batch_id: 60, loss is: [0.16782945], acc is: [0.953125]\n",
"batch_id: 80, loss is: [0.05786889], acc is: [0.96875]\n",
"batch_id: 100, loss is: [0.00799548], acc is: [1.]\n",
"batch_id: 120, loss is: [0.00511317], acc is: [1.]\n",
"batch_id: 140, loss is: [0.01672031], acc is: [1.]\n"
"batch_id: 0, loss is: [0.01201783], acc is: [1.]\n",
"batch_id: 20, loss is: [0.09013407], acc is: [0.984375]\n",
"batch_id: 40, loss is: [0.07025866], acc is: [0.96875]\n",
"batch_id: 60, loss is: [0.08602518], acc is: [0.984375]\n",
"batch_id: 80, loss is: [0.00779913], acc is: [1.]\n",
"batch_id: 100, loss is: [0.00508764], acc is: [1.]\n",
"batch_id: 120, loss is: [0.00401443], acc is: [1.]\n",
"batch_id: 140, loss is: [0.03930391], acc is: [0.96875]\n"
]
}
],
Expand Down
Loading

0 comments on commit ec652b0

Please sign in to comment.