Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ColossalAI
Commits
2144cbae
Commit
2144cbae
authored
Sep 08, 2022
by
Sze-qq
Committed by
Frank Lee
Sep 08, 2022
Browse files
[NFC] polish colossalai/nn/lr_scheduler/multistep.py code style (#1572)
parent
e4bf7ae6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
7 deletions
+17
-7
colossalai/nn/lr_scheduler/multistep.py
colossalai/nn/lr_scheduler/multistep.py
+17
-7
No files found.
colossalai/nn/lr_scheduler/multistep.py
View file @
2144cbae
...
@@ -22,7 +22,13 @@ class MultiStepLR(_MultiStepLR):
...
@@ -22,7 +22,13 @@ class MultiStepLR(_MultiStepLR):
the schedule is started from the beginning or When last_epoch=-1, sets initial lr as lr.
the schedule is started from the beginning or When last_epoch=-1, sets initial lr as lr.
"""
"""
def
__init__
(
self
,
optimizer
,
total_steps
:
int
,
milestones
:
List
[
int
]
=
None
,
gamma
:
float
=
0.1
,
last_epoch
:
int
=
-
1
,
**
kwargs
):
def
__init__
(
self
,
optimizer
,
total_steps
:
int
,
milestones
:
List
[
int
]
=
None
,
gamma
:
float
=
0.1
,
last_epoch
:
int
=
-
1
,
**
kwargs
):
super
().
__init__
(
optimizer
,
milestones
,
gamma
=
gamma
,
last_epoch
=
last_epoch
)
super
().
__init__
(
optimizer
,
milestones
,
gamma
=
gamma
,
last_epoch
=
last_epoch
)
...
@@ -41,12 +47,16 @@ class MultiStepWarmupLR(WarmupScheduler):
...
@@ -41,12 +47,16 @@ class MultiStepWarmupLR(WarmupScheduler):
the schedule is started from the beginning or When last_epoch=-1, sets initial lr as lr.
the schedule is started from the beginning or When last_epoch=-1, sets initial lr as lr.
"""
"""
def
__init__
(
self
,
optimizer
,
total_steps
:
int
,
warmup_steps
:
int
=
0
,
milestones
:
List
[
int
]
=
None
,
def
__init__
(
self
,
gamma
:
float
=
0.1
,
last_epoch
:
int
=
-
1
,
**
kwargs
):
optimizer
,
total_steps
:
int
,
warmup_steps
:
int
=
0
,
milestones
:
List
[
int
]
=
None
,
gamma
:
float
=
0.1
,
last_epoch
:
int
=
-
1
,
**
kwargs
):
if
len
(
milestones
)
==
0
:
if
len
(
milestones
)
==
0
:
raise
ValueError
(
'milestones cannot be empty'
)
raise
ValueError
(
'milestones cannot be empty'
)
milestones
=
[
milestones
=
[
v
-
warmup_steps
for
v
in
milestones
if
v
>=
warmup_steps
]
v
-
warmup_steps
for
v
in
milestones
if
v
>=
warmup_steps
]
base_scheduler
=
_MultiStepLR
(
optimizer
,
milestones
=
milestones
,
gamma
=
gamma
)
base_scheduler
=
_MultiStepLR
(
optimizer
,
milestones
=
milestones
,
gamma
=
gamma
)
super
().
__init__
(
optimizer
,
warmup_steps
,
base_scheduler
,
last_epoch
=
last_epoch
)
super
().
__init__
(
optimizer
,
warmup_steps
,
base_scheduler
,
last_epoch
=
last_epoch
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment