From fa0ae8588e4b4d1168d1b224b285ea156f3998de Mon Sep 17 00:00:00 2001 From: wassname Date: Mon, 12 Oct 2020 13:34:03 +0800 Subject: [PATCH] :bug: --- .../HyperparamOptimization.ipynb | 1280 +---------------- .../HyperparamOptimization.py | 1 - 2 files changed, 53 insertions(+), 1228 deletions(-) diff --git a/notebooks/c06_Hyperparameter_Optimization/HyperparamOptimization.ipynb b/notebooks/c06_Hyperparameter_Optimization/HyperparamOptimization.ipynb index e880edb..869c40b 100644 --- a/notebooks/c06_Hyperparameter_Optimization/HyperparamOptimization.ipynb +++ b/notebooks/c06_Hyperparameter_Optimization/HyperparamOptimization.ipynb @@ -25,15 +25,15 @@ "execution_count": 1, "metadata": { "ExecuteTime": { - "end_time": "2020-10-10T10:30:27.768375Z", - "start_time": "2020-10-10T10:30:26.828537Z" + "end_time": "2020-10-12T05:32:45.890585Z", + "start_time": "2020-10-12T05:32:45.000957Z" } }, "outputs": [ { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 1, @@ -62,8 +62,8 @@ "execution_count": 2, "metadata": { "ExecuteTime": { - "end_time": "2020-10-10T10:30:27.785607Z", - "start_time": "2020-10-10T10:30:27.770961Z" + "end_time": "2020-10-12T05:32:45.909164Z", + "start_time": "2020-10-12T05:32:45.893935Z" } }, "outputs": [ @@ -107,8 +107,8 @@ "execution_count": 3, "metadata": { "ExecuteTime": { - "end_time": "2020-10-10T10:30:27.794951Z", - "start_time": "2020-10-10T10:30:27.789121Z" + "end_time": "2020-10-12T05:32:45.917050Z", + "start_time": "2020-10-12T05:32:45.912884Z" } }, "outputs": [], @@ -121,8 +121,8 @@ "execution_count": 4, "metadata": { "ExecuteTime": { - "end_time": "2020-10-10T10:30:27.805180Z", - "start_time": "2020-10-10T10:30:27.797331Z" + "end_time": "2020-10-12T05:32:45.926592Z", + "start_time": "2020-10-12T05:32:45.919151Z" } }, "outputs": [], @@ -147,8 +147,8 @@ "execution_count": 5, "metadata": { "ExecuteTime": { - "end_time": "2020-10-10T10:30:27.851742Z", - "start_time": "2020-10-10T10:30:27.807861Z" + "end_time": "2020-10-12T05:32:45.976068Z", + "start_time": "2020-10-12T05:32:45.928821Z" } }, "outputs": [], @@ -192,8 +192,8 @@ "execution_count": 6, "metadata": { "ExecuteTime": { - "end_time": "2020-10-10T10:30:27.862747Z", - "start_time": "2020-10-10T10:30:27.855333Z" + "end_time": "2020-10-12T05:32:45.985654Z", + "start_time": "2020-10-12T05:32:45.978381Z" } }, "outputs": [], @@ -230,8 +230,8 @@ "execution_count": 7, "metadata": { "ExecuteTime": { - "end_time": "2020-10-10T10:30:27.877245Z", - "start_time": "2020-10-10T10:30:27.865698Z" + "end_time": "2020-10-12T05:32:46.006848Z", + "start_time": "2020-10-12T05:32:45.989875Z" } }, "outputs": [], @@ -273,8 +273,8 @@ "execution_count": 8, "metadata": { "ExecuteTime": { - "end_time": "2020-10-10T10:30:27.889726Z", - "start_time": "2020-10-10T10:30:27.879498Z" + "end_time": "2020-10-12T05:32:46.031035Z", + "start_time": "2020-10-12T05:32:46.012668Z" } }, "outputs": [], @@ -296,7 +296,6 @@ " optimizer.step() # Update weights\n", " # print statistics\n", " running_loss += loss.item()\n", - " print(running_loss)\n", " running_loss = 0.0\n", "\n", " print(\"Finished Training\")\n", @@ -308,8 +307,8 @@ "execution_count": 9, "metadata": { "ExecuteTime": { - "end_time": "2020-10-10T10:30:27.901522Z", - "start_time": "2020-10-10T10:30:27.891979Z" + "end_time": "2020-10-12T05:32:46.052711Z", + "start_time": "2020-10-12T05:32:46.036067Z" } }, "outputs": [], @@ -348,8 +347,8 @@ "execution_count": 10, "metadata": { "ExecuteTime": { - "end_time": "2020-10-10T10:30:27.922734Z", - "start_time": "2020-10-10T10:30:27.903697Z" + "end_time": "2020-10-12T05:32:46.086001Z", + "start_time": "2020-10-12T05:32:46.056109Z" } }, "outputs": [], @@ -503,11 +502,11 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 11, "metadata": { "ExecuteTime": { - "end_time": "2020-10-10T10:56:14.667829Z", - "start_time": "2020-10-10T10:56:14.649809Z" + "end_time": "2020-10-12T05:32:46.109234Z", + "start_time": "2020-10-12T05:32:46.093352Z" } }, "outputs": [], @@ -654,20 +653,20 @@ "execution_count": 12, "metadata": { "ExecuteTime": { - "end_time": "2020-10-10T10:44:36.932612Z", - "start_time": "2020-10-10T10:30:27.947028Z" + "end_time": "2020-10-12T05:33:15.365301Z", + "start_time": "2020-10-12T05:32:46.112362Z" } }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "c57f6c29c5d14961b849ade09d03c0b4", + "model_id": "efecf6693a8a4ef29980ffabf6294ce3", "version_major": 2, "version_minor": 0 }, "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='gridsearch', max=18.0, style=ProgressStyle(description_wi…" + "HBox(children=(FloatProgress(value=0.0, description='gridsearch', max=1.0, style=ProgressStyle(description_wid…" ] }, "metadata": {}, @@ -683,7 +682,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "30771adf5c18421c8ba9a149662033e5", + "model_id": "3f178fd0a586404cac9c01bee3e0bece", "version_major": 2, "version_minor": 0 }, @@ -697,7 +696,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "", + "model_id": "96d72640117b4b14967a5d4c0eefa5d5", "version_major": 2, "version_minor": 0 }, @@ -709,1057 +708,17 @@ "output_type": "display_data" }, { - "name": "stdout", - "output_type": "stream", - "text": [ - "283.29677771031857\n", - "\n", - "Finished Training\n", - "Evaluation...\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='testing', max=79.0, style=ProgressStyle(description_width…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Accuracy Testing: 0.9815\n", - "Training NN...optimizer:adagrad, activation:selu, epochs:1, learning rate:0.001\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "5ab67236ec0f4642a836e1b3d51a6fe0", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='train', max=1.0, style=ProgressStyle(description_width='i…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='training', max=938.0, style=ProgressStyle(description_wid…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "154.07058791443706\n", - "\n", - "Finished Training\n", - "Evaluation...\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='testing', max=79.0, style=ProgressStyle(description_width…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Accuracy Testing: 0.981\n", - "Training NN...optimizer:sgd, activation:selu, epochs:1, learning rate:0.01\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "cf1228c6479448b6acb948ed5337c245", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='train', max=1.0, style=ProgressStyle(description_width='i…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='training', max=938.0, style=ProgressStyle(description_wid…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "125.51992543414235\n", - "\n", - "Finished Training\n", - "Evaluation...\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='testing', max=79.0, style=ProgressStyle(description_width…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Accuracy Testing: 0.9827\n", - "Training NN...optimizer:sgd, activation:selu, epochs:1, learning rate:0.001\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "62d23211b7314940bc45c1f6dfa49dfe", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='train', max=1.0, style=ProgressStyle(description_width='i…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='training', max=938.0, style=ProgressStyle(description_wid…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "288.13481686636806\n", - "\n", - "Finished Training\n", - "Evaluation...\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='testing', max=79.0, style=ProgressStyle(description_width…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Accuracy Testing: 0.9781\n", - "Training NN...optimizer:adam, activation:selu, epochs:1, learning rate:0.01\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "b3196866700d4242ac2a7538758a6305", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='train', max=1.0, style=ProgressStyle(description_width='i…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='training', max=938.0, style=ProgressStyle(description_wid…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "506.0957414098084\n", - "\n", - "Finished Training\n", - "Evaluation...\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='testing', max=79.0, style=ProgressStyle(description_width…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Accuracy Testing: 0.9618\n", - "Training NN...optimizer:adam, activation:selu, epochs:1, learning rate:0.001\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "bf58c24a34974b04ae013f2d46d780db", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='train', max=1.0, style=ProgressStyle(description_width='i…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='training', max=938.0, style=ProgressStyle(description_wid…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "126.98243455216289\n", - "\n", - "Finished Training\n", - "Evaluation...\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='testing', max=79.0, style=ProgressStyle(description_width…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Accuracy Testing: 0.9783\n", - "Training NN...optimizer:adagrad, activation:tanh, epochs:1, learning rate:0.01\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "0982ae9e8449436f8fe0832523fe7509", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='train', max=1.0, style=ProgressStyle(description_width='i…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='training', max=938.0, style=ProgressStyle(description_wid…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "280.68677139654756\n", - "\n", - "Finished Training\n", - "Evaluation...\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='testing', max=79.0, style=ProgressStyle(description_width…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Accuracy Testing: 0.9807\n", - "Training NN...optimizer:adagrad, activation:tanh, epochs:1, learning rate:0.001\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "c2eb82c0cea341ddbacce8b2c1778428", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='train', max=1.0, style=ProgressStyle(description_width='i…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='training', max=938.0, style=ProgressStyle(description_wid…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "195.68581248819828\n", - "\n", - "Finished Training\n", - "Evaluation...\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='testing', max=79.0, style=ProgressStyle(description_width…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Accuracy Testing: 0.9757\n", - "Training NN...optimizer:sgd, activation:tanh, epochs:1, learning rate:0.01\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "f4a364b46ba24f0a85867d5357bd90d2", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='train', max=1.0, style=ProgressStyle(description_width='i…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='training', max=938.0, style=ProgressStyle(description_wid…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "176.18306627124548\n", - "\n", - "Finished Training\n", - "Evaluation...\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='testing', max=79.0, style=ProgressStyle(description_width…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Accuracy Testing: 0.9849\n", - "Training NN...optimizer:sgd, activation:tanh, epochs:1, learning rate:0.001\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "a1fc4833aaca4fdfa4b72bb356ff735b", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='train', max=1.0, style=ProgressStyle(description_width='i…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='training', max=938.0, style=ProgressStyle(description_wid…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "602.7927330993116\n", - "\n", - "Finished Training\n", - "Evaluation...\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='testing', max=79.0, style=ProgressStyle(description_width…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Accuracy Testing: 0.9608\n", - "Training NN...optimizer:adam, activation:tanh, epochs:1, learning rate:0.01\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "7f40c7a758014ad690464eeff9a0b298", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='train', max=1.0, style=ProgressStyle(description_width='i…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='training', max=938.0, style=ProgressStyle(description_wid…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "397.33486008644104\n", - "\n", - "Finished Training\n", - "Evaluation...\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='testing', max=79.0, style=ProgressStyle(description_width…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Accuracy Testing: 0.9642\n", - "Training NN...optimizer:adam, activation:tanh, epochs:1, learning rate:0.001\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "bd0fc95a1ff249e3a4383241af719d9e", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='train', max=1.0, style=ProgressStyle(description_width='i…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='training', max=938.0, style=ProgressStyle(description_wid…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "141.2712545134127\n", - "\n", - "Finished Training\n", - "Evaluation...\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='testing', max=79.0, style=ProgressStyle(description_width…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Accuracy Testing: 0.9777\n", - "Training NN...optimizer:adagrad, activation:relu, epochs:1, learning rate:0.01\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "4e2d7de88b8a412d95e94d572066719e", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='train', max=1.0, style=ProgressStyle(description_width='i…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='training', max=938.0, style=ProgressStyle(description_wid…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "221.62225933372974\n", - "\n", - "Finished Training\n", - "Evaluation...\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='testing', max=79.0, style=ProgressStyle(description_width…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Accuracy Testing: 0.982\n", - "Training NN...optimizer:adagrad, activation:relu, epochs:1, learning rate:0.001\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "6b7caf89615a43e986298b7a829a2132", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='train', max=1.0, style=ProgressStyle(description_width='i…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='training', max=938.0, style=ProgressStyle(description_wid…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "145.48581282049417\n", - "\n", - "Finished Training\n", - "Evaluation...\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='testing', max=79.0, style=ProgressStyle(description_width…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Accuracy Testing: 0.9818\n", - "Training NN...optimizer:sgd, activation:relu, epochs:1, learning rate:0.01\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "699d6f0d080c43609dbddb1730247d8e", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='train', max=1.0, style=ProgressStyle(description_width='i…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='training', max=938.0, style=ProgressStyle(description_wid…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "124.34220764786005\n", - "\n", - "Finished Training\n", - "Evaluation...\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='testing', max=79.0, style=ProgressStyle(description_width…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Accuracy Testing: 0.9835\n", - "Training NN...optimizer:sgd, activation:relu, epochs:1, learning rate:0.001\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "fc8b8f918212471c83f9cc8ec64ab6ca", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='train', max=1.0, style=ProgressStyle(description_width='i…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='training', max=938.0, style=ProgressStyle(description_wid…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "307.9679284058511\n", - "\n", - "Finished Training\n", - "Evaluation...\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='testing', max=79.0, style=ProgressStyle(description_width…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Accuracy Testing: 0.9793\n", - "Training NN...optimizer:adam, activation:relu, epochs:1, learning rate:0.01\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "0f3f84cf4a1846af8be8112e32373422", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='train', max=1.0, style=ProgressStyle(description_width='i…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='training', max=938.0, style=ProgressStyle(description_wid…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "392.40780045092106\n", - "\n", - "Finished Training\n", - "Evaluation...\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='testing', max=79.0, style=ProgressStyle(description_width…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Accuracy Testing: 0.9776\n", - "Training NN...optimizer:adam, activation:relu, epochs:1, learning rate:0.001\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "18bec26764e94e65bbc774270186b78c", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='train', max=1.0, style=ProgressStyle(description_width='i…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='training', max=938.0, style=ProgressStyle(description_wid…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "113.97934246435761\n", - "\n", - "Finished Training\n", - "Evaluation...\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='testing', max=79.0, style=ProgressStyle(description_width…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Accuracy Testing: 0.9864\n", - "\n", - "{'epoch': 1, 'activation': 'relu', 'optimizer': 'adam', 'learning_rate': 0.001}\n", - "--- 14.149628901481629 minutes ---\n" + "ename": "KeyboardInterrupt", + "evalue": "", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 11\u001b[0m \u001b[0;31m######################################################\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 12\u001b[0m \u001b[0;31m# YOU CODE GOES HERE\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 13\u001b[0;31m \u001b[0mbest_params\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mGridSearch\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtrain_loader\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtest_loader\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mhyperparameters\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 14\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'best_params'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mbest_params\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 15\u001b[0m \u001b[0;31m######################################################\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m\u001b[0m in \u001b[0;36mGridSearch\u001b[0;34m(train_data, test_data, hyperparameters)\u001b[0m\n\u001b[1;32m 54\u001b[0m \u001b[0mn_epochs\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mepochs\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 55\u001b[0m \u001b[0mbs\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m64\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 56\u001b[0;31m \u001b[0mdevice\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mdevice\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 57\u001b[0m )\n\u001b[1;32m 58\u001b[0m \u001b[0maccuracy\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mevaluation\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mclf\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtest_data\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdevice\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m\u001b[0m in \u001b[0;36mtrain\u001b[0;34m(model, dataloader, criterion, optimizer, n_epochs, bs, device)\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0mx\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mx\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mto\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdevice\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0;31m# zero the parameter gradients\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 10\u001b[0;31m \u001b[0moptimizer\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mzero_grad\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 11\u001b[0m \u001b[0;31m# forward + backward + optimize\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 12\u001b[0m \u001b[0moutputs\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmodel\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# Get the prediction here\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/.pyenv/versions/jup3.7.3/lib/python3.7/site-packages/torch/optim/optimizer.py\u001b[0m in \u001b[0;36mzero_grad\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 163\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgrad\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 164\u001b[0m \u001b[0mp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgrad\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdetach_\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 165\u001b[0;31m \u001b[0mp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgrad\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mzero_\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 166\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 167\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mstep\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mclosure\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mKeyboardInterrupt\u001b[0m: " ] } ], @@ -1784,82 +743,23 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": null, "metadata": { "ExecuteTime": { - "end_time": "2020-10-10T10:58:16.421710Z", - "start_time": "2020-10-10T10:56:17.444240Z" - } + "start_time": "2020-10-12T05:33:16.142Z" + }, + "lines_to_next_cell": 0 }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "0842b437cf7642db9001f433c9841903", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='RandomizedGridSearch', max=5.0, style=ProgressStyle(descr…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Training NN...optimizer:adam, activation:selu, epochs:1, learning rate:0.01\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "34b03e6b99c44185b23f051b6ba1e16a", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='train', max=1.0, style=ProgressStyle(description_width='i…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='training', max=938.0, style=ProgressStyle(description_wid…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "530.6996719539165\n", - "\n", - "Finished Training\n", - "Evaluation...\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", + "model_id": "a85be4dfc9134129905ed3b17b906a17", "version_major": 2, "version_minor": 0 }, "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='testing', max=79.0, style=ProgressStyle(description_width…" + "HBox(children=(FloatProgress(value=0.0, description='RandomizedGridSearch', max=1.0, style=ProgressStyle(descr…" ] }, "metadata": {}, @@ -1869,74 +769,13 @@ "name": "stdout", "output_type": "stream", "text": [ - "Accuracy Testing: 0.9728\n", - "Training NN...optimizer:adam, activation:tanh, epochs:1, learning rate:0.01\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "d51cf1f11b484f3d8fbf46348ff5ad08", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='train', max=1.0, style=ProgressStyle(description_width='i…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='training', max=938.0, style=ProgressStyle(description_wid…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "418.68668753281236\n", - "\n", - "Finished Training\n", - "Evaluation...\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(FloatProgress(value=0.0, description='testing', max=79.0, style=ProgressStyle(description_width…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Accuracy Testing: 0.9492\n", - "Training NN...optimizer:sgd, activation:sigmoid, epochs:1, learning rate:0.0001\n" + "Training NN...optimizer:adam, activation:selu, epochs:1, learning rate:0.001\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "d13261331d3c4b42a422d28f2b9df68a", + "model_id": "545a4ae347e64fa9b762cf3d5833935e", "version_major": 2, "version_minor": 0 }, @@ -1950,7 +789,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "2f0f0feba5804514aa46f2b28340b9b4", + "model_id": "fb66b13e7b074f13a196f484cd4afed5", "version_major": 2, "version_minor": 0 }, @@ -1960,21 +799,6 @@ }, "metadata": {}, "output_type": "display_data" - }, - { - "ename": "KeyboardInterrupt", - "evalue": "", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 10\u001b[0m \u001b[0;31m######################################################\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 11\u001b[0m \u001b[0;31m# YOU CODE GOES HERE\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 12\u001b[0;31m \u001b[0mbest_params\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mRandomizedGridSearch\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtrain_loader\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtest_loader\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mhyperparameters\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnum_combinations\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m5\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 13\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbest_params\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 14\u001b[0m \u001b[0;31m######################################################\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m\u001b[0m in \u001b[0;36mRandomizedGridSearch\u001b[0;34m(train_data, test_data, hyperparameters, num_combinations)\u001b[0m\n\u001b[1;32m 32\u001b[0m \u001b[0mn_epochs\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mepochs\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 33\u001b[0m \u001b[0mbs\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m64\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 34\u001b[0;31m \u001b[0mdevice\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mdevice\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 35\u001b[0m )\n\u001b[1;32m 36\u001b[0m \u001b[0;31m# Evaluate\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m\u001b[0m in \u001b[0;36mtrain\u001b[0;34m(model, dataloader, criterion, optimizer, n_epochs, bs, device)\u001b[0m\n\u001b[1;32m 12\u001b[0m \u001b[0moutputs\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmodel\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# Get the prediction here\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 13\u001b[0m \u001b[0mloss\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcriterion\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0moutputs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0my\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# Calculate loss\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 14\u001b[0;31m \u001b[0mloss\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbackward\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# Do backpropagation\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 15\u001b[0m \u001b[0moptimizer\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstep\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# Update weights\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 16\u001b[0m \u001b[0;31m# print statistics\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/.pyenv/versions/jup3.7.3/lib/python3.7/site-packages/torch/tensor.py\u001b[0m in \u001b[0;36mbackward\u001b[0;34m(self, gradient, retain_graph, create_graph)\u001b[0m\n\u001b[1;32m 196\u001b[0m \u001b[0mproducts\u001b[0m\u001b[0;34m.\u001b[0m \u001b[0mDefaults\u001b[0m \u001b[0mto\u001b[0m\u001b[0;31m \u001b[0m\u001b[0;31m`\u001b[0m\u001b[0;31m`\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;31m`\u001b[0m\u001b[0;31m`\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 197\u001b[0m \"\"\"\n\u001b[0;32m--> 198\u001b[0;31m \u001b[0mtorch\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mautograd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbackward\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mgradient\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mretain_graph\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcreate_graph\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 199\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 200\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mregister_hook\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mhook\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/.pyenv/versions/jup3.7.3/lib/python3.7/site-packages/torch/autograd/__init__.py\u001b[0m in \u001b[0;36mbackward\u001b[0;34m(tensors, grad_tensors, retain_graph, create_graph, grad_variables)\u001b[0m\n\u001b[1;32m 98\u001b[0m Variable._execution_engine.run_backward(\n\u001b[1;32m 99\u001b[0m \u001b[0mtensors\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mgrad_tensors\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mretain_graph\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcreate_graph\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 100\u001b[0;31m allow_unreachable=True) # allow_unreachable flag\n\u001b[0m\u001b[1;32m 101\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 102\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mKeyboardInterrupt\u001b[0m: " - ] } ], "source": [ @@ -2005,7 +829,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "lines_to_next_cell": 2 + }, "outputs": [], "source": [] } diff --git a/notebooks/c06_Hyperparameter_Optimization/HyperparamOptimization.py b/notebooks/c06_Hyperparameter_Optimization/HyperparamOptimization.py index 2831ce5..32b6ec2 100644 --- a/notebooks/c06_Hyperparameter_Optimization/HyperparamOptimization.py +++ b/notebooks/c06_Hyperparameter_Optimization/HyperparamOptimization.py @@ -160,7 +160,6 @@ def train(model, dataloader, criterion, optimizer, n_epochs=1, bs=64, device="cp optimizer.step() # Update weights # print statistics running_loss += loss.item() - print(running_loss) running_loss = 0.0 print("Finished Training")