Show epochs as integers on x-axis (#241)

* Show epochs as integers on x-axis

* Update ch07/01_main-chapter-code/previous_chapters.py

* remove extra s

* modify exercise plots

* update chapter 7 plot

* resave ch07 for better file diff
This commit is contained in:
Sebastian Raschka
2024-06-23 07:41:25 -05:00
committed by GitHub
parent 51ca343e83
commit cf0df54d7d
5 changed files with 88 additions and 69 deletions

View File

@@ -1347,6 +1347,8 @@
],
"source": [
"import matplotlib.pyplot as plt\n",
"from matplotlib.ticker import MaxNLocator\n",
"\n",
"\n",
"def plot_losses(epochs_seen, tokens_seen, train_losses, val_losses):\n",
" fig, ax1 = plt.subplots(figsize=(5, 3))\n",
@@ -1357,6 +1359,7 @@
" ax1.set_xlabel(\"Epochs\")\n",
" ax1.set_ylabel(\"Loss\")\n",
" ax1.legend(loc=\"upper right\")\n",
" ax1.xaxis.set_major_locator(MaxNLocator(integer=True)) # only show integer labels on x-axis\n",
"\n",
" # Create a second x-axis for tokens seen\n",
" ax2 = ax1.twiny() # Create a second x-axis that shares the same y-axis\n",
@@ -2455,7 +2458,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.6"
"version": "3.11.4"
}
},
"nbformat": 4,