diff --git a/notebooks/c01_Intro_to_NN_Part_1/Intro_to_NN_Part_1.ipynb b/notebooks/c01_Intro_to_NN_Part_1/Intro_to_NN_Part_1.ipynb index 72fb2ca..b8e1d85 100644 --- a/notebooks/c01_Intro_to_NN_Part_1/Intro_to_NN_Part_1.ipynb +++ b/notebooks/c01_Intro_to_NN_Part_1/Intro_to_NN_Part_1.ipynb @@ -535,6 +535,18 @@ " return clf" ] }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": { + "ExecuteTime": { + "end_time": "2020-11-03T03:44:09.664941Z", + "start_time": "2020-11-03T03:44:09.557535Z" + } + }, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": 28, @@ -576,27 +588,27 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 37, "metadata": { "ExecuteTime": { - "end_time": "2020-11-03T03:39:15.060053Z", - "start_time": "2020-11-03T03:39:14.655024Z" + "end_time": "2020-11-03T03:46:15.168823Z", + "start_time": "2020-11-03T03:46:14.536734Z" } }, "outputs": [ { "data": { "text/plain": [ - "0.7148148148148148" + "0.587037037037037" ] }, - "execution_count": 29, + "execution_count": 37, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "hidden_layers = 10\n", + "hidden_layers = [32, 10]\n", "\n", "# Let's train the model using our custom hyperparameters\n", "clf = train(X_train, y_train, hidden_layers, activation, solver)\n", @@ -650,7 +662,7 @@ " for num_hidden_layers in hyperparameters['hidden_layers']:\n", " print(f'Train NN with solver:{solver}, activation:{activation} and Number of hidden layers:{num_hidden_layers}')\n", " # Let's train the model using our custom hyperparameters\n", - " clf = train(X_train, y_train, num_hidden_layers, activation)\n", + " clf = train(X_train, y_train, num_hidden_layers, activation, solver)\n", " # Let's evaluate the accuracy of the model using the test data\n", " print('Accuracy:',clf.score(X_test, y_test))\n", "```\n", @@ -658,6 +670,18 @@ "" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "ExecuteTime": { + "end_time": "2020-11-03T03:50:02.310907Z", + "start_time": "2020-11-03T03:49:40.529325Z" + } + }, + "outputs": [], + "source": [] + }, { "cell_type": "markdown", "metadata": {}, @@ -692,11 +716,11 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 44, "metadata": { "ExecuteTime": { - "end_time": "2020-11-03T03:34:42.059502Z", - "start_time": "2020-11-03T03:34:34.291609Z" + "end_time": "2020-11-03T05:05:38.141129Z", + "start_time": "2020-11-03T05:05:38.137422Z" } }, "outputs": [ @@ -704,11 +728,11 @@ "name": "stdout", "output_type": "stream", "text": [ - "tensor([[3.0750e-01, 1.7755e-01, 4.9070e-01],\n", - " [1.6806e-01, 4.2704e-01, 1.8621e-01],\n", - " [3.7235e-04, 2.2258e-01, 8.0673e-01],\n", - " [6.3377e-01, 1.4874e-02, 2.7018e-01],\n", - " [4.9504e-01, 4.3858e-01, 1.6609e-02]])\n" + "tensor([[0.5503, 0.4693, 0.7043],\n", + " [0.4956, 0.8336, 0.9000],\n", + " [0.6549, 0.7137, 0.4605],\n", + " [0.0462, 0.2258, 0.0047],\n", + " [0.1696, 0.1850, 0.6982]])\n" ] } ], @@ -730,11 +754,11 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 53, "metadata": { "ExecuteTime": { - "end_time": "2020-11-03T03:34:42.076298Z", - "start_time": "2020-11-03T03:34:42.061886Z" + "end_time": "2020-11-03T05:08:38.124103Z", + "start_time": "2020-11-03T05:08:38.120418Z" } }, "outputs": [ @@ -760,11 +784,11 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 54, "metadata": { "ExecuteTime": { - "end_time": "2020-11-03T03:34:42.126772Z", - "start_time": "2020-11-03T03:34:42.077926Z" + "end_time": "2020-11-03T05:08:38.615472Z", + "start_time": "2020-11-03T05:08:38.611286Z" } }, "outputs": [ @@ -772,7 +796,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "tensor([ 1.4927, -0.8089])\n" + "tensor([-0.6106, 1.8554])\n" ] } ], @@ -783,11 +807,11 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 55, "metadata": { "ExecuteTime": { - "end_time": "2020-11-03T03:34:42.172765Z", - "start_time": "2020-11-03T03:34:42.128057Z" + "end_time": "2020-11-03T05:08:38.760225Z", + "start_time": "2020-11-03T05:08:38.757628Z" } }, "outputs": [ @@ -820,11 +844,11 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 56, "metadata": { "ExecuteTime": { - "end_time": "2020-11-03T03:34:42.220396Z", - "start_time": "2020-11-03T03:34:42.174080Z" + "end_time": "2020-11-03T05:08:40.082228Z", + "start_time": "2020-11-03T05:08:40.078405Z" } }, "outputs": [ @@ -832,7 +856,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "tensor([ 1.4927, -0.8089]) tensor([0.0388, 0.2797])\n" + "tensor([-0.6106, 1.8554]) tensor([0.4771, 0.7711])\n" ] } ], @@ -843,21 +867,21 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 57, "metadata": { "ExecuteTime": { - "end_time": "2020-10-02T05:11:58.844978Z", - "start_time": "2020-10-02T05:11:58.840069Z" + "end_time": "2020-11-03T05:08:41.444623Z", + "start_time": "2020-11-03T05:08:41.440870Z" } }, "outputs": [ { "data": { "text/plain": [ - "tensor([0.4458, 0.8197])" + "tensor([-0.1335, 2.6266])" ] }, - "execution_count": 32, + "execution_count": 57, "metadata": {}, "output_type": "execute_result" } @@ -875,11 +899,11 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 58, "metadata": { "ExecuteTime": { - "end_time": "2020-10-02T05:12:01.647091Z", - "start_time": "2020-10-02T05:12:01.635378Z" + "end_time": "2020-11-03T05:08:43.178190Z", + "start_time": "2020-11-03T05:08:43.174471Z" } }, "outputs": [ @@ -887,7 +911,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "tensor([0.4458, 0.8197])\n" + "tensor([-0.1335, 2.6266])\n" ] } ], @@ -897,11 +921,11 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 59, "metadata": { "ExecuteTime": { - "end_time": "2020-10-02T05:12:10.536381Z", - "start_time": "2020-10-02T05:12:10.527378Z" + "end_time": "2020-11-03T05:08:43.497960Z", + "start_time": "2020-11-03T05:08:43.493299Z" } }, "outputs": [ @@ -909,9 +933,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "tensor([0.0371, 0.1456])\n", - "tensor([ 0.2243, -0.2993])\n", - "tensor([3.0254, 0.4651])\n" + "tensor([-0.2913, 1.4308])\n", + "tensor([-1.0877, 1.0843])\n", + "tensor([-1.2798, 2.4062])\n" ] } ], diff --git a/notebooks/c01_Intro_to_NN_Part_1/Intro_to_NN_Part_1.py b/notebooks/c01_Intro_to_NN_Part_1/Intro_to_NN_Part_1.py index ec423d6..f2ca2e8 100644 --- a/notebooks/c01_Intro_to_NN_Part_1/Intro_to_NN_Part_1.py +++ b/notebooks/c01_Intro_to_NN_Part_1/Intro_to_NN_Part_1.py @@ -226,6 +226,7 @@ def train(X_train, y_train, hidden_layers, activation, solver): return clf + # + hidden_layers = 2 activation = "relu" # ReLU Activation function @@ -240,7 +241,7 @@ def train(X_train, y_train, hidden_layers, activation, solver): # We got an accuracy of 28.3%, which is not really great. Let's try again and train a model changing the number of hidden layers to 10. # + -hidden_layers = 10 +hidden_layers = [32, 10] # Let's train the model using our custom hyperparameters clf = train(X_train, y_train, hidden_layers, activation, solver) @@ -281,13 +282,15 @@ def train(X_train, y_train, hidden_layers, activation, solver): # for num_hidden_layers in hyperparameters['hidden_layers']: # print(f'Train NN with solver:{solver}, activation:{activation} and Number of hidden layers:{num_hidden_layers}') # # Let's train the model using our custom hyperparameters -# clf = train(X_train, y_train, num_hidden_layers, activation) +# clf = train(X_train, y_train, num_hidden_layers, activation, solver) # # Let's evaluate the accuracy of the model using the test data # print('Accuracy:',clf.score(X_test, y_test)) # ``` # # + + # # # 3. Introduction to Pytorch #