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
bc509367
Commit
bc509367
authored
Jan 12, 2023
by
Shondoit
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Call weighted_forward during training
parent
21642000
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
2 deletions
+4
-2
hypernetwork.py
modules/hypernetworks/hypernetwork.py
+2
-1
textual_inversion.py
modules/textual_inversion/textual_inversion.py
+2
-1
No files found.
modules/hypernetworks/hypernetwork.py
View file @
bc509367
...
...
@@ -640,13 +640,14 @@ def train_hypernetwork(id_task, hypernetwork_name, learn_rate, batch_size, gradi
with
devices
.
autocast
():
x
=
batch
.
latent_sample
.
to
(
devices
.
device
,
non_blocking
=
pin_memory
)
w
=
batch
.
weight
.
to
(
devices
.
device
,
non_blocking
=
pin_memory
)
if
tag_drop_out
!=
0
or
shuffle_tags
:
shared
.
sd_model
.
cond_stage_model
.
to
(
devices
.
device
)
c
=
shared
.
sd_model
.
cond_stage_model
(
batch
.
cond_text
)
.
to
(
devices
.
device
,
non_blocking
=
pin_memory
)
shared
.
sd_model
.
cond_stage_model
.
to
(
devices
.
cpu
)
else
:
c
=
stack_conds
(
batch
.
cond
)
.
to
(
devices
.
device
,
non_blocking
=
pin_memory
)
loss
=
shared
.
sd_model
(
x
,
c
)[
0
]
/
gradient_step
loss
=
shared
.
sd_model
.
weighted_forward
(
x
,
c
,
w
)[
0
]
/
gradient_step
del
x
del
c
...
...
modules/textual_inversion/textual_inversion.py
View file @
bc509367
...
...
@@ -480,6 +480,7 @@ def train_embedding(id_task, embedding_name, learn_rate, batch_size, gradient_st
with
devices
.
autocast
():
x
=
batch
.
latent_sample
.
to
(
devices
.
device
,
non_blocking
=
pin_memory
)
w
=
batch
.
weight
.
to
(
devices
.
device
,
non_blocking
=
pin_memory
)
c
=
shared
.
sd_model
.
cond_stage_model
(
batch
.
cond_text
)
if
is_training_inpainting_model
:
...
...
@@ -490,7 +491,7 @@ def train_embedding(id_task, embedding_name, learn_rate, batch_size, gradient_st
else
:
cond
=
c
loss
=
shared
.
sd_model
(
x
,
cond
)[
0
]
/
gradient_step
loss
=
shared
.
sd_model
.
weighted_forward
(
x
,
cond
,
w
)[
0
]
/
gradient_step
del
x
_loss_step
+=
loss
.
item
()
...
...
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