Skip to content

Commit

Permalink
🎨 Applied black
Browse files Browse the repository at this point in the history
  • Loading branch information
jdenholm committed Apr 6, 2024
1 parent 639b63c commit b37663f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
9 changes: 4 additions & 5 deletions worked-solutions/01_penguin_classification_solutions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@
],
"source": [
"from torchvision.transforms import Compose\n",
"\n",
"# import some useful functions here, see https://pytorch.org/docs/stable/torch.html\n",
"# where `tensor` and `eye` are used for constructing tensors,\n",
"# and using a lower-precision float32 is advised for performance\n",
Expand Down Expand Up @@ -736,24 +737,22 @@
"train_metrics, valid_metrics = [], []\n",
"\n",
"\n",
"\n",
"for epoch in range(epochs):\n",
"\n",
" if epoch % print_interval == 0:\n",
" if epoch != 0:\n",
" print(f\"Epoch {max(epoch - print_interval, 0)}-{epoch} time: {perf_counter() - tic:.6f} seconds\")\n",
" print(\n",
" f\"Epoch {max(epoch - print_interval, 0)}-{epoch} time: {perf_counter() - tic:.6f} seconds\"\n",
" )\n",
" tic = perf_counter()\n",
"\n",
"\n",
"\n",
" train_metrics.append(train_one_epoch(model, train_loader, optimiser, loss_func))\n",
"\n",
" valid_metrics.append(validate_one_epoch(model, valid_loader, loss_func))\n",
"\n",
" stop_time = perf_counter()\n",
"\n",
"\n",
"\n",
"print(\"\\n\")\n",
"\n",
"train_metrics = DataFrame(train_metrics)\n",
Expand Down
11 changes: 8 additions & 3 deletions worked-solutions/02_penguin_regression_solutions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -657,10 +657,11 @@
"\n",
" if epoch % print_interval == 0:\n",
" if epoch != 0:\n",
" print(f\"Epoch {max(epoch - print_interval, 0)}-{epoch} time: {perf_counter() - tic:.6f} seconds\")\n",
" print(\n",
" f\"Epoch {max(epoch - print_interval, 0)}-{epoch} time: {perf_counter() - tic:.6f} seconds\"\n",
" )\n",
" tic = perf_counter()\n",
"\n",
"\n",
" train_metrics.append(train_one_epoch(model, train_loader, optimiser, loss_func))\n",
"\n",
" valid_metrics.append(validate_one_epoch(model, valid_loader, loss_func))\n",
Expand Down Expand Up @@ -767,7 +768,11 @@
"\n",
"fig, axis = plt.subplots(1, 1, figsize=(10, 5))\n",
"\n",
"axis.hist(ratios, bins=10, label=fr\"Mean {ratios.mean():.3f}; Std dev. {predictions.std():.3f}\",)\n",
"axis.hist(\n",
" ratios,\n",
" bins=10,\n",
" label=rf\"Mean {ratios.mean():.3f}; Std dev. {predictions.std():.3f}\",\n",
")\n",
"axis.set_xlabel(\"Prediction:target ratio\", fontsize=12)\n",
"axis.set_ylabel(\"Frequency\", fontsize=12)\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion worked-solutions/03_mnist_classification_solutions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@
" Notes\n",
" -----\n",
" - This function assumes the ``preds`` have had the softmax applied to them\n",
" along dimension 1, and that the predicted class is therefore \n",
" along dimension 1, and that the predicted class is therefore\n",
" ``preds.argmax(dim=1)``.\n",
"\n",
" \"\"\"\n",
Expand Down

0 comments on commit b37663f

Please sign in to comment.