Skip to content

Commit a5bc20e

Browse files
wyliKumoLiu
authored andcommitted
tutorial 982 984 fixes occ sens, 987 ce loss (#5323)
Signed-off-by: Wenqi Li <[email protected]> fixes Project-MONAI/tutorials#982 fixes Project-MONAI/tutorials#984 fixes Project-MONAI/tutorials#987 ### Description robust mask size and grid ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [x] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [x] In-line docstrings updated. - [x] Documentation updated, tested `make html` command in the `docs/` folder. Signed-off-by: Wenqi Li <[email protected]> Signed-off-by: KumoLiu <[email protected]>
1 parent f0421e7 commit a5bc20e

14 files changed

+81
-66
lines changed

.github/workflows/cron-mmar.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ jobs:
1818
steps:
1919
- uses: actions/checkout@v3
2020
- name: Set up Python 3.8
21-
uses: actions/setup-python@v3
21+
uses: actions/setup-python@v4
2222
with:
2323
python-version: 3.8
2424
- name: cache weekly timestamp
2525
id: pip-cache
26-
run: echo "::set-output name=datew::$(date '+%Y-%V')"
26+
run: echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
2727
- name: cache for pip
2828
uses: actions/cache@v3
2929
id: cache

.github/workflows/cron.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ jobs:
5353
coverage xml --ignore-errors
5454
if pgrep python; then pkill python; fi
5555
- name: Upload coverage
56-
uses: codecov/codecov-action@v1
56+
uses: codecov/codecov-action@v3
5757
with:
5858
fail_ci_if_error: false
59-
file: ./coverage.xml
59+
files: ./coverage.xml
6060

6161
cron-pt-image:
6262
if: github.repository == 'Project-MONAI/MONAI'
@@ -96,10 +96,10 @@ jobs:
9696
coverage xml --ignore-errors
9797
if pgrep python; then pkill python; fi
9898
- name: Upload coverage
99-
uses: codecov/codecov-action@v1
99+
uses: codecov/codecov-action@v3
100100
with:
101101
fail_ci_if_error: false
102-
file: ./coverage.xml
102+
files: ./coverage.xml
103103

104104
cron-pip:
105105
# pip install monai[all] and use it to run unit tests
@@ -195,10 +195,10 @@ jobs:
195195
coverage xml --ignore-errors
196196
if pgrep python; then pkill python; fi
197197
- name: Upload coverage
198-
uses: codecov/codecov-action@v1
198+
uses: codecov/codecov-action@v3
199199
with:
200200
fail_ci_if_error: false
201-
file: ./coverage.xml
201+
files: ./coverage.xml
202202

203203
cron-tutorial-notebooks:
204204
if: github.repository == 'Project-MONAI/MONAI'
@@ -219,7 +219,7 @@ jobs:
219219
nvidia-smi
220220
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils | tail -n 1)
221221
echo $CUDA_VISIBLE_DEVICES
222-
echo "::set-output name=devices::$CUDA_VISIBLE_DEVICES"
222+
echo "devices=$CUDA_VISIBLE_DEVICES" >> $GITHUB_OUTPUT
223223
- name: Checkout tutorials and install their requirements
224224
run: |
225225
cd /opt

.github/workflows/docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
ref: dev
2626
fetch-depth: 0
2727
- name: Set up Python 3.8
28-
uses: actions/setup-python@v3
28+
uses: actions/setup-python@v4
2929
with:
3030
python-version: 3.8
3131
- shell: bash

.github/workflows/integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: cache weekly timestamp
2121
id: pip-cache
2222
run: |
23-
echo "::set-output name=datew::$(date '+%Y-%V')"
23+
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
2424
- name: cache for pip
2525
uses: actions/cache@v3
2626
id: cache

.github/workflows/pythonapp-gpu.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,6 @@ jobs:
146146
if pgrep python; then pkill python; fi
147147
shell: bash
148148
- name: Upload coverage
149-
uses: codecov/codecov-action@v1
149+
uses: codecov/codecov-action@v3
150150
with:
151-
file: ./coverage.xml
151+
files: ./coverage.xml

.github/workflows/pythonapp-min.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
steps:
3030
- uses: actions/checkout@v3
3131
- name: Set up Python 3.8
32-
uses: actions/setup-python@v3
32+
uses: actions/setup-python@v4
3333
with:
3434
python-version: 3.8
3535
- name: Prepare pip wheel
@@ -39,8 +39,8 @@ jobs:
3939
- name: cache weekly timestamp
4040
id: pip-cache
4141
run: |
42-
echo "::set-output name=datew::$(date '+%Y-%V')"
43-
echo "::set-output name=dir::$(pip cache dir)"
42+
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
43+
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
4444
shell: bash
4545
- name: cache for pip
4646
uses: actions/cache@v3
@@ -79,7 +79,7 @@ jobs:
7979
steps:
8080
- uses: actions/checkout@v3
8181
- name: Set up Python ${{ matrix.python-version }}
82-
uses: actions/setup-python@v3
82+
uses: actions/setup-python@v4
8383
with:
8484
python-version: ${{ matrix.python-version }}
8585
- name: Prepare pip wheel
@@ -89,8 +89,8 @@ jobs:
8989
- name: cache weekly timestamp
9090
id: pip-cache
9191
run: |
92-
echo "::set-output name=datew::$(date '+%Y-%V')"
93-
echo "::set-output name=dir::$(pip cache dir)"
92+
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
93+
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
9494
shell: bash
9595
- name: cache for pip
9696
uses: actions/cache@v3
@@ -124,7 +124,7 @@ jobs:
124124
steps:
125125
- uses: actions/checkout@v3
126126
- name: Set up Python 3.8
127-
uses: actions/setup-python@v3
127+
uses: actions/setup-python@v4
128128
with:
129129
python-version: 3.8
130130
- name: Prepare pip wheel
@@ -134,8 +134,8 @@ jobs:
134134
- name: cache weekly timestamp
135135
id: pip-cache
136136
run: |
137-
echo "::set-output name=datew::$(date '+%Y-%V')"
138-
echo "::set-output name=dir::$(pip cache dir)"
137+
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
138+
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
139139
shell: bash
140140
- name: cache for pip
141141
uses: actions/cache@v3

.github/workflows/pythonapp.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ jobs:
2424
steps:
2525
- uses: actions/checkout@v3
2626
- name: Set up Python 3.8
27-
uses: actions/setup-python@v3
27+
uses: actions/setup-python@v4
2828
with:
2929
python-version: 3.8
3030
- name: cache weekly timestamp
3131
id: pip-cache
3232
run: |
33-
echo "::set-output name=datew::$(date '+%Y-%V')"
33+
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
3434
- name: cache for pip
3535
uses: actions/cache@v3
3636
id: cache
@@ -65,7 +65,7 @@ jobs:
6565
disk-root: "D:"
6666
- uses: actions/checkout@v3
6767
- name: Set up Python 3.8
68-
uses: actions/setup-python@v3
68+
uses: actions/setup-python@v4
6969
with:
7070
python-version: 3.8
7171
- name: Prepare pip wheel
@@ -75,8 +75,8 @@ jobs:
7575
- name: cache weekly timestamp
7676
id: pip-cache
7777
run: |
78-
echo "::set-output name=datew::$(date '+%Y-%V')"
79-
echo "::set-output name=dir::$(pip cache dir)"
78+
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
79+
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
8080
shell: bash
8181
- name: cache for pip
8282
uses: actions/cache@v3
@@ -117,13 +117,13 @@ jobs:
117117
with:
118118
fetch-depth: 0
119119
- name: Set up Python 3.8
120-
uses: actions/setup-python@v3
120+
uses: actions/setup-python@v4
121121
with:
122122
python-version: 3.8
123123
- name: cache weekly timestamp
124124
id: pip-cache
125125
run: |
126-
echo "::set-output name=datew::$(date '+%Y-%V')"
126+
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
127127
- name: cache for pip
128128
uses: actions/cache@v3
129129
id: cache
@@ -150,9 +150,9 @@ jobs:
150150
python setup.py check -m -s
151151
python setup.py sdist bdist_wheel
152152
python -m twine check dist/*
153-
- run: echo "::set-output name=pwd::$PWD"
153+
- run: echo "pwd=$PWD" >> $GITHUB_OUTPUT
154154
id: root
155-
- run: echo "::set-output name=tmp_dir::$(mktemp -d)"
155+
- run: echo "tmp_dir=$(mktemp -d)" >> $GITHUB_OUTPUT
156156
id: mktemp
157157
- name: Move packages
158158
run: |
@@ -198,13 +198,13 @@ jobs:
198198
steps:
199199
- uses: actions/checkout@v3
200200
- name: Set up Python 3.8
201-
uses: actions/setup-python@v3
201+
uses: actions/setup-python@v4
202202
with:
203203
python-version: 3.8
204204
- name: cache weekly timestamp
205205
id: pip-cache
206206
run: |
207-
echo "::set-output name=datew::$(date '+%Y-%V')"
207+
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
208208
- name: cache for pip
209209
uses: actions/cache@v3
210210
id: cache

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
with:
2020
fetch-depth: 0
2121
- name: Set up Python ${{ matrix.python-version }}
22-
uses: actions/setup-python@v3
22+
uses: actions/setup-python@v4
2323
with:
2424
python-version: ${{ matrix.python-version }}
2525
- name: Install setuptools
@@ -96,7 +96,7 @@ jobs:
9696
with:
9797
fetch-depth: 0
9898
- name: Set up Python 3.8
99-
uses: actions/setup-python@v3
99+
uses: actions/setup-python@v4
100100
with:
101101
python-version: 3.8
102102
- shell: bash
@@ -127,7 +127,7 @@ jobs:
127127
name: _version.py
128128
- name: Set tag
129129
id: versioning
130-
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
130+
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
131131
- name: Check tag
132132
env:
133133
RELEASE_VERSION: ${{ steps.versioning.outputs.tag }}

.github/workflows/setupapp.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- name: cache weekly timestamp
3030
id: pip-cache
3131
run: |
32-
echo "::set-output name=datew::$(date '+%Y-%V')"
32+
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
3333
- name: cache for pip
3434
uses: actions/cache@v3
3535
id: cache
@@ -65,10 +65,10 @@ jobs:
6565
if pgrep python; then pkill python; fi
6666
shell: bash
6767
- name: Upload coverage
68-
uses: codecov/codecov-action@v1
68+
uses: codecov/codecov-action@v3
6969
with:
7070
fail_ci_if_error: false
71-
file: ./coverage.xml
71+
files: ./coverage.xml
7272

7373
test-py3x:
7474
runs-on: ubuntu-latest
@@ -80,13 +80,13 @@ jobs:
8080
with:
8181
fetch-depth: 0
8282
- name: Set up Python ${{ matrix.python-version }}
83-
uses: actions/setup-python@v3
83+
uses: actions/setup-python@v4
8484
with:
8585
python-version: ${{ matrix.python-version }}
8686
- name: cache weekly timestamp
8787
id: pip-cache
8888
run: |
89-
echo "::set-output name=datew::$(date '+%Y-%V')"
89+
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
9090
- name: cache for pip
9191
uses: actions/cache@v3
9292
id: cache
@@ -107,22 +107,22 @@ jobs:
107107
BUILD_MONAI=1 ./runtests.sh --build --quick --unittests --disttests
108108
coverage xml --ignore-errors
109109
- name: Upload coverage
110-
uses: codecov/codecov-action@v1
110+
uses: codecov/codecov-action@v3
111111
with:
112112
fail_ci_if_error: false
113-
file: ./coverage.xml
113+
files: ./coverage.xml
114114

115115
install: # pip install from github url, the default branch is dev
116116
runs-on: ubuntu-latest
117117
steps:
118118
- name: Set up Python 3.8
119-
uses: actions/setup-python@v3
119+
uses: actions/setup-python@v4
120120
with:
121121
python-version: 3.8
122122
- name: cache weekly timestamp
123123
id: pip-cache
124124
run: |
125-
echo "::set-output name=datew::$(date '+%Y-%V')"
125+
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
126126
- name: cache for pip
127127
uses: actions/cache@v3
128128
id: cache

.github/workflows/weekly-preview.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
ref: dev
1515
fetch-depth: 0
1616
- name: Set up Python 3.8
17-
uses: actions/setup-python@v3
17+
uses: actions/setup-python@v4
1818
with:
1919
python-version: 3.8
2020
- name: Install setuptools

monai/losses/dice.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,8 @@ def ce(self, input: torch.Tensor, target: torch.Tensor):
711711
"Using argmax (as a workaround) to convert target to a single channel."
712712
)
713713
target = torch.argmax(target, dim=1)
714-
714+
else: # target has the same shape as input, class probabilities in [0, 1], as floats
715+
target = target.to(input) # check its values are in [0, 1]??
715716
return self.cross_entropy(input, target)
716717

717718
def forward(self, input: torch.Tensor, target: torch.Tensor) -> torch.Tensor:

0 commit comments

Comments
 (0)