Skip to content

Commit

Permalink
add img and minor fix
Browse files Browse the repository at this point in the history
Change-Id: I859208ab078d787bd6021a33fb4fc9a12f9aed4f
  • Loading branch information
roywei committed Jul 10, 2020
1 parent e2b0f8b commit 768c654
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 42 deletions.
2 changes: 1 addition & 1 deletion chapter_multilayer-perceptrons/dropout.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@
"DefaultTrainingConfig config = new DefaultTrainingConfig(loss)\n",
" .optOptimizer(sgd) // Optimizer (loss function)\n",
" .addEvaluator(new Accuracy()) // Model Accuracy\n",
" .addTrainingListeners(TrainingListener.Defaults.basic()); // Logging\n",
" .addTrainingListeners(TrainingListener.Defaults.logging()); // Logging\n",
"\n",
" try (Model model = Model.newInstance(\"mlp\")) {\n",
" model.setBlock(net);\n",
Expand Down
27 changes: 17 additions & 10 deletions chapter_multilayer-perceptrons/mlp-djl.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -33,7 +33,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -47,7 +47,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -56,7 +56,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -110,7 +110,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {
"attributes": {
"classes": [],
Expand Down Expand Up @@ -144,7 +144,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -183,7 +183,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {
"attributes": {
"classes": [],
Expand All @@ -201,7 +201,7 @@
"DefaultTrainingConfig config = new DefaultTrainingConfig(loss)\n",
" .optOptimizer(sgd) // Optimizer (loss function)\n",
" .addEvaluator(new Accuracy()) // Model Accuracy\n",
" .addTrainingListeners(TrainingListener.Defaults.basic()); // Logging\n",
" .addTrainingListeners(TrainingListener.Defaults.logging()); // Logging\n",
"\n",
" try (Model model = Model.newInstance(\"mlp\")) {\n",
" model.setBlock(net);\n",
Expand All @@ -228,7 +228,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -252,6 +252,13 @@
"render(LinePlot.create(\"\", data, \"epochCount\", \"loss\", \"lossLabel\"),\"text/html\");"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![lineplot](https://d2l-java-resources.s3.amazonaws.com/img/chapter_multilayer-perceptrons_mlp-djl_output1.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -284,7 +291,7 @@
"mimetype": "text/x-java-source",
"name": "Java",
"pygments_lexer": "java",
"version": "11.0.5+10-LTS"
"version": "12.0.2+9-Ubuntu-116.04"
}
},
"nbformat": 4,
Expand Down
40 changes: 20 additions & 20 deletions chapter_multilayer-perceptrons/mlp-scratch.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {
"attributes": {
"classes": [],
Expand All @@ -39,7 +39,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -53,7 +53,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -64,7 +64,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -105,7 +105,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {
"attributes": {
"classes": [],
Expand Down Expand Up @@ -163,7 +163,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {
"attributes": {
"classes": [],
Expand Down Expand Up @@ -207,7 +207,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {
"attributes": {
"classes": [],
Expand Down Expand Up @@ -237,7 +237,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {
"attributes": {
"classes": [],
Expand Down Expand Up @@ -276,7 +276,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {
"attributes": {
"classes": [],
Expand Down Expand Up @@ -306,7 +306,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -326,7 +326,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"metadata": {
"attributes": {
"classes": [],
Expand Down Expand Up @@ -390,7 +390,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -410,6 +410,13 @@
"render(LinePlot.create(\"\", data, \"epochCount\", \"loss\", \"lossLabel\"),\"text/html\");"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![lineplot](https://d2l-java-resources.s3.amazonaws.com/img/chapter_multilayer-perceptrons_mlp-scratch_output1.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -432,13 +439,6 @@
"1. What is the smartest strategy you can think of for structuring a search over multiple hyperparameters?\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -453,7 +453,7 @@
"mimetype": "text/x-java-source",
"name": "Java",
"pygments_lexer": "java",
"version": "11.0.5+10-LTS"
"version": "12.0.2+9-Ubuntu-116.04"
}
},
"nbformat": 4,
Expand Down
49 changes: 44 additions & 5 deletions chapter_multilayer-perceptrons/mlp.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,13 @@
"render(LinePlot.create(\"\", data, \"x\", \"relu(X)\"), \"text/html\");"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![relu](https://d2l-java-resources.s3.amazonaws.com/img/chapter_multilayer-perceptrons_mlp_relu.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -447,6 +454,13 @@
"render(LinePlot.create(\"\", data, \"x\", \"grad of relu\"), \"text/html\");"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![grad_relu](https://d2l-java-resources.s3.amazonaws.com/img/chapter_multilayer-perceptrons_mlp_grad_relu.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -539,6 +553,13 @@
"render(LinePlot.create(\"\", data, \"x\", \"sigmoid(X)\")); "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![sigmoid](https://d2l-java-resources.s3.amazonaws.com/img/chapter_multilayer-perceptrons_mlp_sigmoid.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -591,6 +612,13 @@
"render(LinePlot.create(\"\", data, \"x\", \"grad of sigmoid\"), \"text/html\");"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![grad_sigmoid](https://d2l-java-resources.s3.amazonaws.com/img/chapter_multilayer-perceptrons_mlp_grad_sigmoid.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -632,6 +660,13 @@
"render(LinePlot.create(\"\", data, \"x\", \"tanh(X)\"));"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![tanh](https://d2l-java-resources.s3.amazonaws.com/img/chapter_multilayer-perceptrons_mlp_tanh.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -683,6 +718,13 @@
"render(LinePlot.create(\"\", data, \"x\", \"grad of tanh\"), \"text/html\");"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![grad_tanh](https://d2l-java-resources.s3.amazonaws.com/img/chapter_multilayer-perceptrons_mlp_grad_tanh.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -713,10 +755,7 @@
"1. Show that a multilayer perceptron using only ReLU (or pReLU) constructs a continuous piecewise linear function.\n",
"1. Show that $\\mathrm{tanh}(x) + 1 = 2 \\mathrm{sigmoid}(2x)$.\n",
"1. Assume we have a multilayer perceptron *without* nonlinearities between the layers. In particular, assume that we have $d$ input dimensions, $d$ output dimensions and that one of the layers has only $d/2$ dimensions. Show that this network is less expressive (powerful) than a single layer perceptron.\n",
"1. Assume that we have a nonlinearity that applies to one minibatch at a time. What kinds of problems do you expect this to cause?\n",
"\n",
"\n",
"![](https://raw.githubusercontent.com/d2l-ai/d2l-en/master/img/qr_mlp.svg)"
"1. Assume that we have a nonlinearity that applies to one minibatch at a time. What kinds of problems do you expect this to cause?\n"
]
}
],
Expand All @@ -732,7 +771,7 @@
"mimetype": "text/x-java-source",
"name": "Java",
"pygments_lexer": "java",
"version": "11.0.5+10-LTS"
"version": "12.0.2+9-Ubuntu-116.04"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 768c654

Please sign in to comment.