Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

update several notebooks #894

Merged
merged 1 commit into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

100 changes: 49 additions & 51 deletions paddle2.0_docs/dynamic_graph/dynamic_graph.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"0.0.0\n",
"89af2088b6e74bdfeef2d4d78e08461ed2aafee5\n"
"2.0.0-beta0\n"
]
}
],
Expand All @@ -40,8 +39,7 @@
"import numpy as np\n",
"\n",
"paddle.disable_static()\n",
"print(paddle.__version__)\n",
"print(paddle.__git_commit__)\n"
"print(paddle.__version__)"
]
},
{
Expand All @@ -62,16 +60,16 @@
"name": "stdout",
"output_type": "stream",
"text": [
"[[-0.49341336 -0.8112665 ]\n",
" [ 0.8929015 0.24661176]\n",
" [-0.64440054 -0.7945008 ]\n",
" [-0.07345356 1.3641853 ]]\n",
"[[ 1.5645729 -0.74514765]\n",
" [-0.01248 0.68240154]\n",
" [ 0.11316949 -1.6579045 ]\n",
" [-0.1425675 -1.0153968 ]]\n",
"[1. 2.]\n",
"[[0.5065867 1.1887336 ]\n",
" [1.8929014 2.2466118 ]\n",
" [0.35559946 1.2054992 ]\n",
" [0.92654645 3.3641853 ]]\n",
"[-2.1159463 1.386125 -2.2334023 2.654917 ]\n"
"[[2.5645728 1.2548523 ]\n",
" [0.98752 2.6824017 ]\n",
" [1.1131694 0.3420955 ]\n",
" [0.8574325 0.98460317]]\n",
"[ 0.07427764 1.352323 -3.2026396 -2.173361 ]\n"
]
}
],
Expand Down Expand Up @@ -100,20 +98,20 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0 +> [5 6 7]\n",
"1 +> [5 7 9]\n",
"1 -> [-3 -3 -3]\n",
"2 +> [ 5 9 15]\n",
"3 -> [-3 3 21]\n",
"4 -> [-3 11 75]\n",
"5 +> [ 5 37 249]\n",
"6 +> [ 5 69 735]\n",
"4 +> [ 5 21 87]\n",
"5 -> [ -3 27 237]\n",
"6 -> [ -3 59 723]\n",
"7 -> [ -3 123 2181]\n",
"8 +> [ 5 261 6567]\n",
"9 +> [ 5 517 19689]\n"
Expand Down Expand Up @@ -146,7 +144,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -172,28 +170,28 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0 [2.0915627]\n",
"200 [0.67530334]\n",
"400 [0.52042854]\n",
"600 [0.28010666]\n",
"800 [0.09739777]\n",
"1000 [0.09307177]\n",
"1200 [0.04252927]\n",
"1400 [0.03095707]\n",
"1600 [0.03022156]\n",
"1800 [0.01616007]\n",
"2000 [0.01069116]\n",
"2200 [0.0055158]\n",
"2400 [0.00195092]\n",
"2600 [0.00101116]\n",
"2800 [0.00192219]\n"
"0 [1.3384138]\n",
"200 [0.7855983]\n",
"400 [0.59084535]\n",
"600 [0.30849028]\n",
"800 [0.26992702]\n",
"1000 [0.03990713]\n",
"1200 [0.07111286]\n",
"1400 [0.01177792]\n",
"1600 [0.03160322]\n",
"1800 [0.02757282]\n",
"2000 [0.00916022]\n",
"2200 [0.00217024]\n",
"2400 [0.00186833]\n",
"2600 [0.00101926]\n",
"2800 [0.0009654]\n"
]
}
],
Expand All @@ -220,8 +218,8 @@
" print(t, loss.numpy())\n",
"\n",
" loss.backward()\n",
" optimizer.minimize(loss)\n",
" model.clear_gradients()"
" optimizer.step()\n",
" optimizer.clear_grad()"
]
},
{
Expand All @@ -230,29 +228,29 @@
"source": [
"# 构建更加灵活的网络:共享权重\n",
"\n",
"- 使用动态图还可以更加方便的创建共享权重的网络,下面的示例展示了一个共享了权重的简单的AutoEncoder的示例。\n",
"- 使用动态图还可以更加方便的创建共享权重的网络,下面的示例展示了一个共享了权重的简单的AutoEncoder。\n",
"- 你也可以参考图像搜索的示例看到共享参数权重的更实际的使用。"
]
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"step: 0, loss: [0.37666085]\n",
"step: 1, loss: [0.3063845]\n",
"step: 2, loss: [0.2647248]\n",
"step: 3, loss: [0.23831272]\n",
"step: 4, loss: [0.21714918]\n",
"step: 5, loss: [0.1955545]\n",
"step: 6, loss: [0.17261818]\n",
"step: 7, loss: [0.15009595]\n",
"step: 8, loss: [0.13051331]\n",
"step: 9, loss: [0.11537809]\n"
"step: 0, loss: [0.33474904]\n",
"step: 1, loss: [0.31669515]\n",
"step: 2, loss: [0.29729688]\n",
"step: 3, loss: [0.27288628]\n",
"step: 4, loss: [0.24694422]\n",
"step: 5, loss: [0.2203041]\n",
"step: 6, loss: [0.19171436]\n",
"step: 7, loss: [0.16213782]\n",
"step: 8, loss: [0.13443354]\n",
"step: 9, loss: [0.11170781]\n"
]
}
],
Expand All @@ -270,8 +268,8 @@
" loss = loss_fn(outputs, inputs)\n",
" loss.backward()\n",
" print(\"step: {}, loss: {}\".format(i, loss.numpy()))\n",
" optimizer.minimize(loss)\n",
" linear.clear_gradients()"
" optimizer.step()\n",
" optimizer.clear_grad()"
]
},
{
Expand Down
46 changes: 23 additions & 23 deletions paddle2.0_docs/hello_paddle/hello_paddle.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 22,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -90,21 +90,21 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"paddle version 0.0.0\n"
"paddle 2.0.0-beta0\n"
]
}
],
"source": [
"import paddle\n",
"paddle.disable_static()\n",
"print(\"paddle version \" + paddle.__version__)"
"print(\"paddle \" + paddle.__version__)"
]
},
{
Expand All @@ -121,7 +121,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -150,7 +150,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -168,14 +168,14 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"w before optimize: -1.7107375860214233\n",
"w before optimize: -1.696260690689087\n",
"b before optimize: 0.0\n"
]
}
Expand Down Expand Up @@ -205,7 +205,7 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -224,19 +224,19 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"epoch 0 loss [2107.3943]\n",
"epoch 1000 loss [7.8432994]\n",
"epoch 2000 loss [1.7537074]\n",
"epoch 3000 loss [0.39211753]\n",
"epoch 4000 loss [0.08767726]\n",
"finished training, loss [0.01963376]\n"
"epoch 0 loss [2094.069]\n",
"epoch 1000 loss [7.8451133]\n",
"epoch 2000 loss [1.7541145]\n",
"epoch 3000 loss [0.39221546]\n",
"epoch 4000 loss [0.08769739]\n",
"finished training, loss [0.0196382]\n"
]
}
],
Expand All @@ -246,8 +246,8 @@
" y_predict = linear(x_data)\n",
" loss = mse_loss(y_predict, y_data)\n",
" loss.backward()\n",
" sgd_optimizer.minimize(loss)\n",
" linear.clear_gradients()\n",
" sgd_optimizer.step()\n",
" sgd_optimizer.clear_grad()\n",
" \n",
" if i%1000 == 0:\n",
" print(\"epoch {} loss {}\".format(i, loss.numpy()))\n",
Expand All @@ -266,15 +266,15 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"w after optimize: 2.017843246459961\n",
"b after optimize: 9.771851539611816\n"
"w after optimize: 2.0178451538085938\n",
"b after optimize: 9.771825790405273\n"
]
}
],
Expand All @@ -297,7 +297,7 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": 10,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -339,5 +339,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 1
"nbformat_minor": 4
}
Loading