diff --git a/MONAICore/3. End-To-End Workflow with MONAI - Solution.ipynb b/MONAICore/3. End-To-End Workflow with MONAI - Solution.ipynb index 76169cc..d152c21 100644 --- a/MONAICore/3. End-To-End Workflow with MONAI - Solution.ipynb +++ b/MONAICore/3. End-To-End Workflow with MONAI - Solution.ipynb @@ -450,7 +450,8 @@ " print(f\"epoch {epoch + 1}/{epoch_num}\")\n", "\n", " epoch_loss = 0\n", - " step = 1\n", + " step = 0\n", + " total_items = 0\n", "\n", " steps_per_epoch = len(train_ds) // train_loader.batch_size\n", "\n", @@ -478,11 +479,12 @@ " # and its internal optimisation strategy\n", " optimizer.step()\n", "\n", - " epoch_loss += loss.item()\n", - " print(f\"{step}/{len(train_ds) // train_loader.batch_size + 1}, training_loss: {loss.item():.4f}\")\n", + " epoch_loss += loss.item() * outputs.shape[0]\n", + " total_items += outputs.shape[0]\n", + " print(f\"{step + 1}/{len(train_ds) // train_loader.batch_size + 1}, training_loss: {loss.item():.4f}\")\n", " step += 1\n", "\n", - " epoch_loss /= step\n", + " epoch_loss /= total_items\n", " epoch_loss_values.append(epoch_loss)\n", " print(f\"epoch {epoch + 1} average loss: {epoch_loss:.4f}\")\n", "\n", diff --git a/MONAICore/3. End-To-End Workflow with MONAI.ipynb b/MONAICore/3. End-To-End Workflow with MONAI.ipynb index 01f6529..f37a979 100644 --- a/MONAICore/3. End-To-End Workflow with MONAI.ipynb +++ b/MONAICore/3. End-To-End Workflow with MONAI.ipynb @@ -450,7 +450,8 @@ " print(f\"epoch {epoch + 1}/{epoch_num}\")\n", "\n", " epoch_loss = 0\n", - " step = 1\n", + " step = 0\n", + " total_items = 0\n", "\n", " steps_per_epoch = len(train_ds) // train_loader.batch_size\n", "\n", @@ -478,11 +479,12 @@ " # and its internal optimisation strategy\n", " optimizer.step()\n", "\n", - " epoch_loss += loss.item()\n", - " print(f\"{step}/{len(train_ds) // train_loader.batch_size + 1}, training_loss: {loss.item():.4f}\")\n", + " epoch_loss += loss.item() * outputs.shape[0]\n", + " total_items += outputs.shape[0]\n", + " print(f\"{step + 1}/{len(train_ds) // train_loader.batch_size + 1}, training_loss: {loss.item():.4f}\")\n", " step += 1\n", "\n", - " epoch_loss /= step\n", + " epoch_loss /= total_items\n", " epoch_loss_values.append(epoch_loss)\n", " print(f\"epoch {epoch + 1} average loss: {epoch_loss:.4f}\")\n", "\n", diff --git a/MONAICore/MONAI Bundle, MONAI Model Zoo, and Image Visualization.ipynb b/MONAICore/MONAI Bundle, MONAI Model Zoo, and Image Visualization.ipynb index c8efa0f..8e3daf3 100644 --- a/MONAICore/MONAI Bundle, MONAI Model Zoo, and Image Visualization.ipynb +++ b/MONAICore/MONAI Bundle, MONAI Model Zoo, and Image Visualization.ipynb @@ -109,7 +109,11 @@ "source": [ "## MONAI Bundle\n", "\n", - "The objective of the MONAI bundle is to define a packaged model which includes the critical information necessary to allow users and programs to understand how the model is used and what purpose it is for. A bundle includes the stored weights of a single network as a pickled state dictionary plus optionally a Torchscript object and/or an ONNX object. Additional JSON files are included to store metadata about the model, information for constructing training, inference, and post-processing transform sequences, plain-text description, legal information, and other data the model creator wishes to include." + "MONAI bundles define a packaged model which includes the critical information necessary to allow users and programs to understand how the model is used and what purpose it is for. \n", + "\n", + "* Stored weights of a single network as a pickled state dictionary are included, plus optional Torchscript and/or ONNX object. \n", + "\n", + "* Additional JSON files store metadata about the model, information for constructing training, inference, and post-processing transform sequences, plain-text description, legal information, and other data the model creator wishes to include." ] }, { @@ -210,7 +214,7 @@ } }, "source": [ - "or alternatively, in `YAML` format (`demo_config.yaml`):\n", + "Alternatively, in `YAML` format (`demo_config.yaml`):\n", "\n", "```yaml\n", "demo_net:\n",