Refactor code for improved readability and consistency across multiple Jupyter notebooks

- Added missing commas in various print statements and function calls for better syntax.
- Reformatted code to enhance clarity, including breaking long lines and aligning parameters.
- Updated function signatures to use float type for sigma parameters instead of int for better precision.
- Cleaned up comments and documentation strings for clarity and consistency.
- Ensured consistent formatting in plotting functions and data handling.
This commit is contained in:
2025-12-13 23:38:17 +01:00
parent f89ff4a016
commit d5a6bfd339
50 changed files with 779 additions and 449 deletions

View File

@@ -58,7 +58,10 @@
"from sklearn.model_selection import train_test_split\n",
"\n",
"X_train, X_valid, y_train, y_valid = train_test_split(\n",
" X_train_full, y_train_full, test_size=0.2, random_state=42\n",
" X_train_full,\n",
" y_train_full,\n",
" test_size=0.2,\n",
" random_state=42,\n",
")\n",
"print(X_train.shape, y_train.shape)\n",
"print(X_valid.shape, y_valid.shape)"
@@ -181,7 +184,7 @@
" keras.layers.Dense(256, activation=\"relu\"),\n",
" keras.layers.Dense(128, activation=\"relu\"),\n",
" keras.layers.Dense(10, activation=\"softmax\"),\n",
" ]\n",
" ],\n",
")"
]
},
@@ -563,7 +566,7 @@
" keras.layers.Dense(256, activation=\"relu\"),\n",
" keras.layers.Dense(128, activation=\"relu\"),\n",
" keras.layers.Dense(10, activation=\"softmax\"),\n",
" ]\n",
" ],\n",
" )\n",
" model.compile(\n",
" loss=\"sparse_categorical_crossentropy\",\n",
@@ -673,7 +676,10 @@
" plt.subplot(1, 2, 1)\n",
" plt.plot(history_df[\"val_loss\"], linestyle=\"--\", color=colors[_])\n",
" plt.plot(\n",
" history_df[\"loss\"], label=f\"LR={learning_rate}\", alpha=0.5, color=colors[_]\n",
" history_df[\"loss\"],\n",
" label=f\"LR={learning_rate}\",\n",
" alpha=0.5,\n",
" color=colors[_],\n",
" )\n",
" plt.xlabel(\"Epochs\")\n",
" plt.ylabel(\"Loss\")\n",