diff --git a/12-regularization.ipynb b/12-regularization.ipynb index 7e9215ade..55fb0e97f 100644 --- a/12-regularization.ipynb +++ b/12-regularization.ipynb @@ -27,6 +27,16 @@ " ...]```" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Install old version of torchtext\n", + "# %pip install cmp_version torchtext==0.6.0" + ] + }, { "cell_type": "code", "execution_count": null, @@ -37,7 +47,7 @@ "import matplotlib.pyplot as plt\n", "%matplotlib inline\n", "\n", - "# Checnking for module version \n", + "# Checking for module version \n", "from cmp_version import cmp_version \n", "\n", "# PyTorch imports\n", @@ -173,7 +183,7 @@ "source": [ "# Print most common vocabulary text\n", "most_common_samples = 10\n", - "print(text.vocab.freqs.most_common(most_common_samples))" + "print(*text.vocab.freqs.most_common(most_common_samples), sep='\\n')" ] }, { @@ -242,7 +252,12 @@ "outputs": [], "source": [ "# Check if iterator above is an iterable which should show True\n", - "isinstance(train_loader, collections.Iterable)" + "try:\n", + " from collections.abc import Iterable # noqa\n", + "except ImportError:\n", + " from collections import Iterable # noqa\n", + "\n", + "isinstance(train_loader, Iterable)" ] }, { @@ -381,7 +396,7 @@ " out = torch.relu(out)\n", " \n", " # Toggle 3: Dropout\n", - " # out = torch.dropout(out, 0.8)\n", + " out = torch.dropout(out, 0.8, train=True)\n", "\n", " # Linear function (readout)\n", " # Take note here use a final sigmoid function so your loss should not go through sigmoid again.\n", @@ -608,27 +623,22 @@ " weights_nothing.reshape(-1),\n", " weights_L1.reshape(-1),\n", " weights_L2.reshape(-1),\n", + " weights_dropout.reshape(-1),\n", "), 49, range=(-.5, .5), label=(\n", " 'No-reg',\n", " 'L1',\n", " 'L2',\n", + " 'Dropout'\n", "))\n", "plt.legend();" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python [conda env:dl-minicourse] *", + "display_name": "Python 3", "language": "python", - "name": "conda-env-dl-minicourse-py" + "name": "python3" }, "language_info": { "codemirror_mode": { @@ -640,7 +650,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.3" + "version": "3.10.6" } }, "nbformat": 4,