Skip to content

Commit 531b681

Browse files
committed
Issue #690: added doc regarding reduction strategy in loss
1 parent 0234ee9 commit 531b681

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

deepreg/loss/image.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ def __init__(
2929
Init.
3030
3131
:param reduction: using SUM reduction over batch axis,
32+
this is for supporting multi-device training,
33+
and the loss will be divided by global batch size,
3234
calling the loss like `loss(y_true, y_pred)` will return a scalar tensor.
3335
:param name: name of the loss
3436
"""
@@ -70,6 +72,8 @@ def __init__(
7072
:param num_bins: number of bins for intensity, the default value is empirical.
7173
:param sigma_ratio: a hyper param for gaussian function
7274
:param reduction: using SUM reduction over batch axis,
75+
this is for supporting multi-device training,
76+
and the loss will be divided by global batch size,
7377
calling the loss like `loss(y_true, y_pred)` will return a scalar tensor.
7478
:param name: name of the loss
7579
"""
@@ -201,6 +205,8 @@ def __init__(
201205
:param smooth_nr: small constant added to numerator in case of zero covariance.
202206
:param smooth_dr: small constant added to denominator in case of zero variance.
203207
:param reduction: using SUM reduction over batch axis,
208+
this is for supporting multi-device training,
209+
and the loss will be divided by global batch size,
204210
calling the loss like `loss(y_true, y_pred)` will return a scalar tensor.
205211
:param name: name of the loss
206212
"""

deepreg/loss/label.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ def __init__(
3434
:param scales: list of scalars or None, if None, do not apply any scaling.
3535
:param kernel: gaussian or cauchy.
3636
:param reduction: using SUM reduction over batch axis,
37+
this is for supporting multi-device training,
38+
and the loss will be divided by global batch size,
3739
calling the loss like `loss(y_true, y_pred)` will return a scalar tensor.
3840
:param name: str, name of the loss.
3941
"""
@@ -132,6 +134,8 @@ def __init__(
132134
:param scales: list of scalars or None, if None, do not apply any scaling.
133135
:param kernel: gaussian or cauchy.
134136
:param reduction: using SUM reduction over batch axis,
137+
this is for supporting multi-device training,
138+
and the loss will be divided by global batch size,
135139
calling the loss like `loss(y_true, y_pred)` will return a scalar tensor.
136140
:param name: str, name of the loss.
137141
"""
@@ -206,6 +210,8 @@ def __init__(
206210
:param scales: list of scalars or None, if None, do not apply any scaling.
207211
:param kernel: gaussian or cauchy.
208212
:param reduction: using SUM reduction over batch axis,
213+
this is for supporting multi-device training,
214+
and the loss will be divided by global batch size,
209215
calling the loss like `loss(y_true, y_pred)` will return a scalar tensor.
210216
:param name: str, name of the loss.
211217
"""
@@ -272,6 +278,8 @@ def __init__(
272278
:param scales: list of scalars or None, if None, do not apply any scaling.
273279
:param kernel: gaussian or cauchy.
274280
:param reduction: using SUM reduction over batch axis,
281+
this is for supporting multi-device training,
282+
and the loss will be divided by global batch size,
275283
calling the loss like `loss(y_true, y_pred)` will return a scalar tensor.
276284
:param name: str, name of the loss.
277285
"""

examples/custom_image_label_loss.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ def __init__(
2222
Init.
2323
2424
:param reduction: using SUM reduction over batch axis,
25+
this is for supporting multi-device training,
26+
and the loss will be divided by global batch size,
2527
calling the loss like `loss(y_true, y_pred)` will return a scalar tensor.
2628
:param name: name of the loss
2729
"""

examples/custom_parameterized_image_label_loss.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ def __init__(
2424
2525
:param p: order of the norm, 1 or 2.
2626
:param reduction: using SUM reduction over batch axis,
27+
this is for supporting multi-device training,
28+
and the loss will be divided by global batch size,
2729
calling the loss like `loss(y_true, y_pred)` will return a scalar tensor.
2830
:param name: name of the loss.
2931
"""

0 commit comments

Comments
 (0)