From 5f688dc3ace81ac5dbb4865bff501d57d8df1f77 Mon Sep 17 00:00:00 2001 From: JackWang0318 Date: Sat, 13 Apr 2024 14:58:25 +0800 Subject: [PATCH 1/2] Add advanced rnn-vis to lstm.ipynb and slight cell tag in rnn.ipynb --- .../deep-learning/lstm.ipynb | 66 +++++++++++++++++-- .../deep-learning/rnn.ipynb | 21 ++---- 2 files changed, 65 insertions(+), 22 deletions(-) diff --git a/open-machine-learning-jupyter-book/deep-learning/lstm.ipynb b/open-machine-learning-jupyter-book/deep-learning/lstm.ipynb index 6ea5b6e8f..292239447 100644 --- a/open-machine-learning-jupyter-book/deep-learning/lstm.ipynb +++ b/open-machine-learning-jupyter-book/deep-learning/lstm.ipynb @@ -48,9 +48,59 @@ "The vanilla LSTM is proposed in 2005, the paper is [Bidirectional LSTM Networks for Improved Phoneme Classification and Recognition](https://link.springer.com/chapter/10.1007/11550907_126), and after that, a lot of paper based on it appeared.\n" ] }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [ + "hide-input" + ] + }, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + "

\n", + "\n", + "A demo of advanced RNNs. [source]\n", + "

\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "from IPython.display import HTML\n", + "display(HTML(\"\"\"\n", + "

\n", + "\n", + "A demo of advanced RNNs. [source]\n", + "

\n", + "\"\"\"))" + ] + }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "source": [ "## Overview\n", "The essential problems of RNN are vanishing/exploding gradient problems. The gradient vanishing/exploding problem is a common issue in training deep neural networks. This problem occurs when the gradient of the loss function with respect to the weights of the network becomes very small or very large.\n", @@ -75,7 +125,13 @@ }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "source": [ "## Special Gates\n", "Then, we take a look at the inside of cell. $\\bigodot$ means element-wise multiplication operator, $\\bigoplus$ means element-wise addition operator and $\\sigma$ means logistic sigmoid activation functions.\n", @@ -4780,7 +4836,7 @@ ], "metadata": { "kernelspec": { - "display_name": "open-machine-learning-jupyter-book", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -4794,9 +4850,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.9.18" } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/open-machine-learning-jupyter-book/deep-learning/rnn.ipynb b/open-machine-learning-jupyter-book/deep-learning/rnn.ipynb index 7c1bf555d..7358486a4 100644 --- a/open-machine-learning-jupyter-book/deep-learning/rnn.ipynb +++ b/open-machine-learning-jupyter-book/deep-learning/rnn.ipynb @@ -6,7 +6,7 @@ "id": "4f92eda8", "metadata": { "tags": [ - "hide-input" + "hide-cell" ] }, "outputs": [ @@ -79,23 +79,10 @@ "id": "298a6e8c", "metadata": {}, "source": [ - ":::{figure} https://static-1300131294.cos.ap-shanghai.myqcloud.com/images/deep-learning/RNN/rnn1.png\n", - "---\n", - "name: 'RNN1'\n", - "width: 90%\n", - "---\n", - "RNN1\n", - ":::\n", - "\n", - "If unroll over a sequence $(x_0,x_1,x_2)$.\n", + "| ![RNN1](https://static-1300131294.cos.ap-shanghai.myqcloud.com/images/deep-learning/RNN/rnn1.png) | ![RNN2](https://static-1300131294.cos.ap-shanghai.myqcloud.com/images/deep-learning/RNN/rnn2.png) |\n", + "|:--:|:--:|\n", + "| RNN1 (recurrent) | RNN2 (unfolded RNN1) |\n", "\n", - ":::{figure} https://static-1300131294.cos.ap-shanghai.myqcloud.com/images/deep-learning/RNN/rnn2.png\n", - "---\n", - "name: 'RNN2'\n", - "width: 90%\n", - "---\n", - "RNN2\n", - ":::\n", "\n", "Then, the input (w0,w1,...,wt) sequence of words ( 1-hot encoded ) and the output (w1,w2,...,wt+1) shifted sequence of words ( 1-hot encoded ) have the following relation.\n", "\n", From ceecb42c9572925dfad041bc2d72971d68ee9693 Mon Sep 17 00:00:00 2001 From: JackWang <99715727+JackWang0318@users.noreply.github.com> Date: Sat, 13 Apr 2024 15:08:39 +0800 Subject: [PATCH 2/2] Update lstm.ipynb --- .../deep-learning/lstm.ipynb | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/open-machine-learning-jupyter-book/deep-learning/lstm.ipynb b/open-machine-learning-jupyter-book/deep-learning/lstm.ipynb index 292239447..1b6c54323 100644 --- a/open-machine-learning-jupyter-book/deep-learning/lstm.ipynb +++ b/open-machine-learning-jupyter-book/deep-learning/lstm.ipynb @@ -94,13 +94,7 @@ }, { "cell_type": "markdown", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, + "metadata": {}, "source": [ "## Overview\n", "The essential problems of RNN are vanishing/exploding gradient problems. The gradient vanishing/exploding problem is a common issue in training deep neural networks. This problem occurs when the gradient of the loss function with respect to the weights of the network becomes very small or very large.\n", @@ -125,13 +119,7 @@ }, { "cell_type": "markdown", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, + "metadata": {}, "source": [ "## Special Gates\n", "Then, we take a look at the inside of cell. $\\bigodot$ means element-wise multiplication operator, $\\bigoplus$ means element-wise addition operator and $\\sigma$ means logistic sigmoid activation functions.\n", @@ -4836,7 +4824,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "open-machine-learning-jupyter-book", "language": "python", "name": "python3" }, @@ -4850,7 +4838,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.18" + "version": "3.9.16" } }, "nbformat": 4,