diff --git "a/notebook.ipynb" "b/notebook.ipynb" --- "a/notebook.ipynb" +++ "b/notebook.ipynb" @@ -6,7 +6,7 @@ "source": [ "## How does a neural net really work\n", "\n", - "In this notebook I'm exploring fast.ai's Kaggle notebook on [\"How does a neural net really work\"](https://www.kaggle.com/code/jhoward/how-does-a-neural-net-really-work). This relates to [Lesson 3 of the fast.ai Deep Learning course](https://course.fast.ai/Lessons/lesson3.html). While the video provides a solid explanation, the enigmatic imports and variables can be difficult to comprehend. I'm reimplementing some sections to see if if sticks. In a nutshell, this is what is happening in this notebook:\n", + "In this notebook I'm exploring fast.ai's Kaggle notebook on [\"How does a neural net really work\"](https://www.kaggle.com/code/jhoward/how-does-a-neural-net-really-work). This relates to [Lesson 3](https://course.fast.ai/Lessons/lesson3.html) and [Lesson 5](https://course.fast.ai/Lessons/lesson5.html) of the fast.ai Deep Learning course. While the video provides a solid explanation, the enigmatic imports and variables can be difficult to comprehend. I'm reimplementing some sections to see if if sticks. In a nutshell, this is what is happening in this notebook:\n", "\n", "1. Revising Regressions \n", " - Plot a generic quadratic function ($ax^2 + bx + c$) \n", @@ -14,9 +14,10 @@ " - Learn the step-by-step process to find the values of `a`, `b`, and `c` that make our function represent the random data generated in `2` \n", " - Use the [mean absolute error](https://docs.fast.ai/metrics.html#mae) to manually adjust `a`, `b`, and `c`. \n", "2. Understand and break down the Gradient Descent algorithm\n", - "3. The Basics of a Neural-Network\n", - " - Understand what is a ReLU\n", - " - Create the simplest neural-network possible" + "3. The Basics of a Neural-Network using the Titanic Survival dataset form Kaggle\n", + " - Explore ReLUs and how it differs from a simpel linear function\n", + " - Build a single-layer neural network using a simple linear function $f(x) = m*x$ (m being a array of weights that we multiply by our features)\n", + " - Do Deep Learning by layering coefficients/wheights/neurons to do a multi-layer neural network" ] }, { @@ -24,10 +25,10 @@ "execution_count": 1, "metadata": { "execution": { - "iopub.execute_input": "2025-02-28T14:26:01.063845Z", - "iopub.status.busy": "2025-02-28T14:26:01.063279Z", - "iopub.status.idle": "2025-02-28T14:26:02.706607Z", - "shell.execute_reply": "2025-02-28T14:26:02.705945Z" + "iopub.execute_input": "2025-03-04T16:43:18.516396Z", + "iopub.status.busy": "2025-03-04T16:43:18.515931Z", + "iopub.status.idle": "2025-03-04T16:43:20.469155Z", + "shell.execute_reply": "2025-03-04T16:43:20.468442Z" } }, "outputs": [ @@ -41,14 +42,17 @@ ], "source": [ "# Installing the dependencies within the notebook to make it easier to run on colab\n", - "%pip install -Uqq fastai==2.7.18 ipywidgets==8.1.5 plotly==5.24.1" + "%pip install -Uqq fastai==2.7.18 ipywidgets==8.1.5 plotly==5.24.1 datasets==3.3.2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "## 1. Revising Regressions" + "## 1. Revising Regressions\n", + " \n", + "This section, from the fast.ai course, sets the stage for understanding how neural networks learn \"weights\". \n", + "We'll plot some points on a graphic and use visualizations to see how changing the coefficients affects the function to better fit the points." ] }, { @@ -63,15 +67,21 @@ "execution_count": 2, "metadata": { "execution": { - "iopub.execute_input": "2025-02-28T14:26:02.741204Z", - "iopub.status.busy": "2025-02-28T14:26:02.741000Z", - "iopub.status.idle": "2025-02-28T14:26:04.442990Z", - "shell.execute_reply": "2025-02-28T14:26:04.442698Z" + "iopub.execute_input": "2025-03-04T16:43:20.502799Z", + "iopub.status.busy": "2025-03-04T16:43:20.502615Z", + "iopub.status.idle": "2025-03-04T16:43:22.296560Z", + "shell.execute_reply": "2025-03-04T16:43:22.296267Z" } }, "outputs": [], "source": [ "from fastai.basics import torch, plt\n", + "import numpy as np, pandas as pd\n", + "\n", + "# Make pandas and numpy use the entire screan\n", + "np.set_printoptions(linewidth=140)\n", + "torch.set_printoptions(linewidth=140, sci_mode=False, edgeitems=7)\n", + "pd.set_option('display.width', 140)\n", "\n", "# Set the figure DPI to 90 for better resolution\n", "plt.rc('figure', dpi=90)\n", @@ -93,10 +103,10 @@ "execution_count": 3, "metadata": { "execution": { - "iopub.execute_input": "2025-02-28T14:26:04.444557Z", - "iopub.status.busy": "2025-02-28T14:26:04.444386Z", - "iopub.status.idle": "2025-02-28T14:26:04.565319Z", - "shell.execute_reply": "2025-02-28T14:26:04.565045Z" + "iopub.execute_input": "2025-03-04T16:43:22.298117Z", + "iopub.status.busy": "2025-03-04T16:43:22.297959Z", + "iopub.status.idle": "2025-03-04T16:43:22.420309Z", + "shell.execute_reply": "2025-03-04T16:43:22.420023Z" } }, "outputs": [ @@ -142,10 +152,10 @@ "execution_count": 4, "metadata": { "execution": { - "iopub.execute_input": "2025-02-28T14:26:04.566754Z", - "iopub.status.busy": "2025-02-28T14:26:04.566629Z", - "iopub.status.idle": "2025-02-28T14:26:04.618344Z", - "shell.execute_reply": "2025-02-28T14:26:04.618081Z" + "iopub.execute_input": "2025-03-04T16:43:22.421798Z", + "iopub.status.busy": "2025-03-04T16:43:22.421679Z", + "iopub.status.idle": "2025-03-04T16:43:22.473127Z", + "shell.execute_reply": "2025-03-04T16:43:22.472853Z" } }, "outputs": [ @@ -197,17 +207,17 @@ "execution_count": 5, "metadata": { "execution": { - "iopub.execute_input": "2025-02-28T14:26:04.619814Z", - "iopub.status.busy": "2025-02-28T14:26:04.619716Z", - "iopub.status.idle": "2025-02-28T14:26:04.700789Z", - "shell.execute_reply": "2025-02-28T14:26:04.700518Z" + "iopub.execute_input": "2025-03-04T16:43:22.474508Z", + "iopub.status.busy": "2025-03-04T16:43:22.474417Z", + "iopub.status.idle": "2025-03-04T16:43:22.603991Z", + "shell.execute_reply": "2025-03-04T16:43:22.603715Z" } }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "a968c18476a64679865d4e155b830426", + "model_id": "59ec2153978b4daf8390111eab5d783b", "version_major": 2, "version_minor": 0 }, @@ -249,10 +259,10 @@ "execution_count": 6, "metadata": { "execution": { - "iopub.execute_input": "2025-02-28T14:26:04.702683Z", - "iopub.status.busy": "2025-02-28T14:26:04.702598Z", - "iopub.status.idle": "2025-02-28T14:26:04.705903Z", - "shell.execute_reply": "2025-02-28T14:26:04.705648Z" + "iopub.execute_input": "2025-03-04T16:43:22.605818Z", + "iopub.status.busy": "2025-03-04T16:43:22.605729Z", + "iopub.status.idle": "2025-03-04T16:43:22.609154Z", + "shell.execute_reply": "2025-03-04T16:43:22.608917Z" } }, "outputs": [ @@ -296,17 +306,17 @@ "execution_count": 7, "metadata": { "execution": { - "iopub.execute_input": "2025-02-28T14:26:04.707270Z", - "iopub.status.busy": "2025-02-28T14:26:04.707180Z", - "iopub.status.idle": "2025-02-28T14:26:04.756700Z", - "shell.execute_reply": "2025-02-28T14:26:04.756430Z" + "iopub.execute_input": "2025-03-04T16:43:22.610351Z", + "iopub.status.busy": "2025-03-04T16:43:22.610265Z", + "iopub.status.idle": "2025-03-04T16:43:22.659219Z", + "shell.execute_reply": "2025-03-04T16:43:22.658942Z" } }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "cffd9415d34e4a65a8786ec9d2db966e", + "model_id": "f42bc9cda3ff4b8c8ec13eaff97be107", "version_major": 2, "version_minor": 0 }, @@ -357,10 +367,10 @@ "execution_count": 8, "metadata": { "execution": { - "iopub.execute_input": "2025-02-28T14:26:04.758624Z", - "iopub.status.busy": "2025-02-28T14:26:04.758539Z", - "iopub.status.idle": "2025-02-28T14:26:05.103721Z", - "shell.execute_reply": "2025-02-28T14:26:05.103433Z" + "iopub.execute_input": "2025-03-04T16:43:22.661051Z", + "iopub.status.busy": "2025-03-04T16:43:22.660959Z", + "iopub.status.idle": "2025-03-04T16:43:22.932359Z", + "shell.execute_reply": "2025-03-04T16:43:22.932064Z" } }, "outputs": [ @@ -12040,9 +12050,9 @@ } }, "text/html": [ - "