Skip to content

Commit 421cfa8

Browse files
Bordacarmocca
andauthored
Apply suggestions from code review
Co-authored-by: Carlos Mocholí <[email protected]>
1 parent ced1052 commit 421cfa8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pytorch_lightning/callbacks/stochastic_weight_avg.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ def __init__(
102102
if isinstance(swa_epoch_start, float) and not (0 <= swa_epoch_start <= 1):
103103
raise MisconfigurationException(err_msg)
104104

105-
_wrong_type = not isinstance(swa_lrs, (float, list))
106-
_wrong_float = isinstance(swa_lrs, float) and swa_lrs <= 0
107-
_wrong_list = isinstance(swa_lrs, list) and not all(lr > 0 and isinstance(lr, float) for lr in swa_lrs)
108-
if (swa_lrs is not None and (_wrong_type or _wrong_float or _wrong_list)):
105+
wrong_type = not isinstance(swa_lrs, (float, list))
106+
wrong_float = isinstance(swa_lrs, float) and swa_lrs <= 0
107+
wrong_list = isinstance(swa_lrs, list) and not all(lr > 0 and isinstance(lr, float) for lr in swa_lrs)
108+
if (swa_lrs is not None and (wrong_type or wrong_float or wrong_list)):
109109
raise MisconfigurationException("The `swa_lrs` should be a positive float or a list of positive float.")
110110

111111
if avg_fn is not None and not isinstance(avg_fn, Callable):

0 commit comments

Comments
 (0)