Skip to content

fixes EnsureChannel dice_loss_metric_notes #964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions modules/dice_loss_metric_notes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"import torch\n",
"from monai.losses import DiceLoss\n",
"from monai.metrics import DiceMetric\n",
"from monai.transforms import EnsureChannelFirst, AsDiscrete, Compose\n",
"from monai.transforms import AsDiscrete, Compose\n",
"\n",
"\n",
"def print_tensor(name, t):\n",
Expand Down Expand Up @@ -108,7 +108,7 @@
"outputs": [],
"source": [
"# make one hot and add batch dimension\n",
"make_2_class = Compose([AsDiscrete(to_onehot=2), EnsureChannelFirst()])\n",
"make_2_class = Compose([AsDiscrete(to_onehot=2), lambda x: x[None]])\n",
"\n",
"grnd2 = make_2_class(grnd)\n",
"pred2 = make_2_class(pred)"
Expand Down Expand Up @@ -305,7 +305,7 @@
"outputs": [],
"source": [
"# make one hot and add batch dimension\n",
"make_3_class = Compose([AsDiscrete(to_onehot=3), EnsureChannelFirst()])\n",
"make_3_class = Compose([AsDiscrete(to_onehot=3), lambda x: x[None]])\n",
"\n",
"mgrnd2 = make_3_class(mgrnd)\n",
"mpred2 = make_3_class(mpred)"
Expand Down Expand Up @@ -412,7 +412,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.13"
"version": "3.8.12"
}
},
"nbformat": 4,
Expand Down