Remove unnecessary matplotlib import from losses module

Issue: xor_crisis.py was failing with ImportError on matplotlib architecture mismatch
Root cause: losses_dev.py imported matplotlib.pyplot but never used it

Fix:
-  Removed unused imports: matplotlib.pyplot, time
-  Re-exported module 04_losses to update tinytorch package
-  Verified both milestone 02 scripts now run successfully

The matplotlib import was causing failures on M2 Macs where matplotlib
was installed for wrong architecture (x86_64 vs arm64). Since it was
never used, removing it eliminates the dependency entirely.

Tested:
-  milestones/02_xor_crisis_1969/xor_crisis.py (49% accuracy - expected failure)
-  milestones/02_xor_crisis_1969/xor_solved.py (100% accuracy - perfect!)
This commit is contained in:
Vijay Janapa Reddi
2025-09-30 14:16:42 -04:00
parent 5066d91877
commit 82fd89d5b3
4 changed files with 126 additions and 37 deletions

View File

@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "9d798b1c",
"id": "dc4a8074",
"metadata": {
"cell_marker": "\"\"\""
},
@@ -35,7 +35,7 @@
},
{
"cell_type": "markdown",
"id": "91804987",
"id": "08ab6b0b",
"metadata": {
"cell_marker": "\"\"\""
},
@@ -59,7 +59,7 @@
},
{
"cell_type": "markdown",
"id": "c09dc686",
"id": "848eaef7",
"metadata": {
"cell_marker": "\"\"\""
},
@@ -80,7 +80,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "51189bc1",
"id": "90d6651a",
"metadata": {
"nbgrader": {
"grade": false,
@@ -94,8 +94,6 @@
"#| export\n",
"\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import time\n",
"from typing import Optional\n",
"\n",
"def import_previous_module(module_name: str, component_name: str):\n",
@@ -113,7 +111,7 @@
},
{
"cell_type": "markdown",
"id": "cc227c2d",
"id": "529a8e8a",
"metadata": {
"cell_marker": "\"\"\""
},
@@ -189,7 +187,7 @@
},
{
"cell_type": "markdown",
"id": "49e5039b",
"id": "4e69ba6d",
"metadata": {
"cell_marker": "\"\"\""
},
@@ -235,7 +233,7 @@
},
{
"cell_type": "markdown",
"id": "b1e1cbd0",
"id": "b9a1fa2c",
"metadata": {
"cell_marker": "\"\"\""
},
@@ -247,7 +245,7 @@
},
{
"cell_type": "markdown",
"id": "820e9937",
"id": "bf3b7915",
"metadata": {
"cell_marker": "\"\"\"",
"lines_to_next_cell": 1
@@ -297,7 +295,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "854758b3",
"id": "085562d6",
"metadata": {
"lines_to_next_cell": 1,
"nbgrader": {
@@ -348,7 +346,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "6b57e650",
"id": "d274d1e1",
"metadata": {
"nbgrader": {
"grade": true,
@@ -389,7 +387,7 @@
},
{
"cell_type": "markdown",
"id": "b8be9f2c",
"id": "d51980c3",
"metadata": {
"cell_marker": "\"\"\"",
"lines_to_next_cell": 1
@@ -459,7 +457,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "aca5154a",
"id": "1107bf9d",
"metadata": {
"lines_to_next_cell": 1,
"nbgrader": {
@@ -531,7 +529,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "7391538b",
"id": "80f97626",
"metadata": {
"nbgrader": {
"grade": true,
@@ -577,7 +575,7 @@
},
{
"cell_type": "markdown",
"id": "0b9b254c",
"id": "14b2d795",
"metadata": {
"cell_marker": "\"\"\"",
"lines_to_next_cell": 1
@@ -670,7 +668,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "eb59fb50",
"id": "c0a10af0",
"metadata": {
"lines_to_next_cell": 1,
"nbgrader": {
@@ -746,7 +744,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "c59fbbfd",
"id": "24685fb9",
"metadata": {
"nbgrader": {
"grade": true,
@@ -797,7 +795,7 @@
},
{
"cell_type": "markdown",
"id": "599727d1",
"id": "68a261f3",
"metadata": {
"cell_marker": "\"\"\"",
"lines_to_next_cell": 1
@@ -906,7 +904,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "54a20f3f",
"id": "b02977aa",
"metadata": {
"lines_to_next_cell": 1,
"nbgrader": {
@@ -982,7 +980,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "1bab9d23",
"id": "722d5c07",
"metadata": {
"nbgrader": {
"grade": true,
@@ -1033,7 +1031,7 @@
},
{
"cell_type": "markdown",
"id": "ca40b581",
"id": "88bad600",
"metadata": {
"cell_marker": "\"\"\"",
"lines_to_next_cell": 1
@@ -1090,7 +1088,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "76b4eb81",
"id": "b5a701fe",
"metadata": {
"nbgrader": {
"grade": false,
@@ -1146,7 +1144,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "b90c91f0",
"id": "35891a55",
"metadata": {
"nbgrader": {
"grade": false,
@@ -1211,7 +1209,7 @@
},
{
"cell_type": "markdown",
"id": "e2fc1aa7",
"id": "95e3f483",
"metadata": {
"cell_marker": "\"\"\"",
"lines_to_next_cell": 1
@@ -1286,7 +1284,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "573fa75d",
"id": "c46f9468",
"metadata": {
"nbgrader": {
"grade": false,
@@ -1336,7 +1334,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "b7f12c78",
"id": "d95c49f1",
"metadata": {
"nbgrader": {
"grade": false,
@@ -1393,7 +1391,7 @@
},
{
"cell_type": "markdown",
"id": "4c6ebac9",
"id": "88afe536",
"metadata": {
"cell_marker": "\"\"\"",
"lines_to_next_cell": 1
@@ -1457,7 +1455,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "d0b635c1",
"id": "232f8764",
"metadata": {
"nbgrader": {
"grade": false,
@@ -1513,7 +1511,7 @@
},
{
"cell_type": "markdown",
"id": "d770e887",
"id": "f00b5616",
"metadata": {
"cell_marker": "\"\"\""
},
@@ -1526,7 +1524,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "55fd411d",
"id": "76ec7947",
"metadata": {
"nbgrader": {
"grade": true,
@@ -1606,7 +1604,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "b66f2370",
"id": "e635a52d",
"metadata": {
"lines_to_next_cell": 2
},
@@ -1619,7 +1617,7 @@
},
{
"cell_type": "markdown",
"id": "ce0d9c33",
"id": "da28d331",
"metadata": {
"cell_marker": "\"\"\""
},

View File

@@ -79,8 +79,6 @@ The `import_previous_module()` function below helps us cleanly import components
#| export
import numpy as np
import matplotlib.pyplot as plt
import time
from typing import Optional
def import_previous_module(module_name: str, component_name: str):