From 768c65467abceafacbd462b70d30b6d4802a3ca6 Mon Sep 17 00:00:00 2001 From: Lai Wei Date: Thu, 9 Jul 2020 20:29:50 +0000 Subject: [PATCH] add img and minor fix Change-Id: I859208ab078d787bd6021a33fb4fc9a12f9aed4f --- chapter_multilayer-perceptrons/dropout.ipynb | 2 +- chapter_multilayer-perceptrons/mlp-djl.ipynb | 27 ++++++---- .../mlp-scratch.ipynb | 40 +++++++-------- chapter_multilayer-perceptrons/mlp.ipynb | 49 +++++++++++++++++-- .../numerical-stability-and-init.ipynb | 19 ++++--- 5 files changed, 95 insertions(+), 42 deletions(-) diff --git a/chapter_multilayer-perceptrons/dropout.ipynb b/chapter_multilayer-perceptrons/dropout.ipynb index d53cb856..d482e698 100644 --- a/chapter_multilayer-perceptrons/dropout.ipynb +++ b/chapter_multilayer-perceptrons/dropout.ipynb @@ -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", diff --git a/chapter_multilayer-perceptrons/mlp-djl.ipynb b/chapter_multilayer-perceptrons/mlp-djl.ipynb index 487cb737..1a7b6167 100644 --- a/chapter_multilayer-perceptrons/mlp-djl.ipynb +++ b/chapter_multilayer-perceptrons/mlp-djl.ipynb @@ -16,7 +16,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -33,7 +33,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -47,7 +47,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -56,7 +56,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -110,7 +110,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": { "attributes": { "classes": [], @@ -144,7 +144,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -183,7 +183,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": { "attributes": { "classes": [], @@ -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", @@ -228,7 +228,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -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": {}, @@ -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, diff --git a/chapter_multilayer-perceptrons/mlp-scratch.ipynb b/chapter_multilayer-perceptrons/mlp-scratch.ipynb index 43f2d378..dad15f9e 100644 --- a/chapter_multilayer-perceptrons/mlp-scratch.ipynb +++ b/chapter_multilayer-perceptrons/mlp-scratch.ipynb @@ -16,7 +16,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": { "attributes": { "classes": [], @@ -39,7 +39,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -53,7 +53,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -64,7 +64,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -105,7 +105,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": { "attributes": { "classes": [], @@ -163,7 +163,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": { "attributes": { "classes": [], @@ -207,7 +207,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": { "attributes": { "classes": [], @@ -237,7 +237,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": { "attributes": { "classes": [], @@ -276,7 +276,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "metadata": { "attributes": { "classes": [], @@ -306,7 +306,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -326,7 +326,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "metadata": { "attributes": { "classes": [], @@ -390,7 +390,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -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": {}, @@ -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": { @@ -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, diff --git a/chapter_multilayer-perceptrons/mlp.ipynb b/chapter_multilayer-perceptrons/mlp.ipynb index a84d6446..7784bec9 100644 --- a/chapter_multilayer-perceptrons/mlp.ipynb +++ b/chapter_multilayer-perceptrons/mlp.ipynb @@ -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": {}, @@ -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": {}, @@ -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": {}, @@ -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": {}, @@ -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": {}, @@ -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": {}, @@ -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" ] } ], @@ -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, diff --git a/chapter_multilayer-perceptrons/numerical-stability-and-init.ipynb b/chapter_multilayer-perceptrons/numerical-stability-and-init.ipynb index c0d54d47..6799853f 100644 --- a/chapter_multilayer-perceptrons/numerical-stability-and-init.ipynb +++ b/chapter_multilayer-perceptrons/numerical-stability-and-init.ipynb @@ -112,7 +112,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -126,7 +126,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -137,7 +137,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -160,7 +160,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -198,6 +198,13 @@ "render(LinePlot.create(\"\", data, \"x\", \"grad of relu\", \"groups\"), \"text/html\");" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "![lineplot](https://d2l-java-resources.s3.amazonaws.com/img/chapter_multilayer-perceptrons_numerical-stability-and-init.png)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -234,7 +241,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": { "attributes": { "classes": [], @@ -431,7 +438,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,