Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
stable-diffusion-webui
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
stable-diffusion-webui
Commits
3dc9a43f
Unverified
Commit
3dc9a43f
authored
Oct 30, 2022
by
AUTOMATIC1111
Committed by
GitHub
Oct 30, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3898 from R-N/lr-comma
Allow trailing comma in learning rate
parents
5612d030
ef4c94e1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
14 deletions
+21
-14
learn_schedule.py
modules/textual_inversion/learn_schedule.py
+21
-14
No files found.
modules/textual_inversion/learn_schedule.py
View file @
3dc9a43f
...
...
@@ -4,30 +4,37 @@ import tqdm
class
LearnScheduleIterator
:
def
__init__
(
self
,
learn_rate
,
max_steps
,
cur_step
=
0
):
"""
specify learn_rate as "0.001:100, 0.00001:1000, 1e-5:10000" to have lr of 0.001 until step 100, 0.00001 until 1000,
1e-5:10000
until 10000
specify learn_rate as "0.001:100, 0.00001:1000, 1e-5:10000" to have lr of 0.001 until step 100, 0.00001 until 1000,
and 1e-5
until 10000
"""
pairs
=
learn_rate
.
split
(
','
)
self
.
rates
=
[]
self
.
it
=
0
self
.
maxit
=
0
for
i
,
pair
in
enumerate
(
pairs
):
tmp
=
pair
.
split
(
':'
)
if
len
(
tmp
)
==
2
:
step
=
int
(
tmp
[
1
])
if
step
>
cur_step
:
self
.
rates
.
append
((
float
(
tmp
[
0
]),
min
(
step
,
max_steps
)))
self
.
maxit
+=
1
if
step
>
max_steps
:
try
:
for
i
,
pair
in
enumerate
(
pairs
):
if
not
pair
.
strip
():
continue
tmp
=
pair
.
split
(
':'
)
if
len
(
tmp
)
==
2
:
step
=
int
(
tmp
[
1
])
if
step
>
cur_step
:
self
.
rates
.
append
((
float
(
tmp
[
0
]),
min
(
step
,
max_steps
)))
self
.
maxit
+=
1
if
step
>
max_steps
:
return
elif
step
==
-
1
:
self
.
rates
.
append
((
float
(
tmp
[
0
]),
max_steps
))
self
.
maxit
+=
1
return
el
if
step
==
-
1
:
el
se
:
self
.
rates
.
append
((
float
(
tmp
[
0
]),
max_steps
))
self
.
maxit
+=
1
return
else
:
self
.
rates
.
append
((
float
(
tmp
[
0
]),
max_steps
))
self
.
maxit
+=
1
return
assert
self
.
rates
except
(
ValueError
,
AssertionError
):
raise
Exception
(
'Invalid learning rate schedule. It should be a number or, for example, like "0.001:100, 0.00001:1000, 1e-5:10000" to have lr of 0.001 until step 100, 0.00001 until 1000, and 1e-5 until 10000.'
)
def
__iter__
(
self
):
return
self
...
...
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