Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
diffusers
Commits
e4fe9413
Unverified
Commit
e4fe9413
authored
Dec 30, 2022
by
Suraj Patil
Committed by
GitHub
Dec 30, 2022
Browse files
[examples] update loss computation (#1861)
update loss computation
parent
ac373846
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
2 deletions
+3
-2
examples/dreambooth/train_dreambooth.py
examples/dreambooth/train_dreambooth.py
+1
-1
examples/textual_inversion/textual_inversion.py
examples/textual_inversion/textual_inversion.py
+2
-1
No files found.
examples/dreambooth/train_dreambooth.py
View file @
e4fe9413
...
...
@@ -732,7 +732,7 @@ def main(args):
target
,
target_prior
=
torch
.
chunk
(
target
,
2
,
dim
=
0
)
# Compute instance loss
loss
=
F
.
mse_loss
(
model_pred
.
float
(),
target
.
float
(),
reduction
=
"
none"
).
mean
([
1
,
2
,
3
]).
mean
(
)
loss
=
F
.
mse_loss
(
model_pred
.
float
(),
target
.
float
(),
reduction
=
"
mean"
)
# Compute prior loss
prior_loss
=
F
.
mse_loss
(
model_pred_prior
.
float
(),
target_prior
.
float
(),
reduction
=
"mean"
)
...
...
examples/textual_inversion/textual_inversion.py
View file @
e4fe9413
...
...
@@ -634,7 +634,8 @@ def main():
else
:
raise
ValueError
(
f
"Unknown prediction type
{
noise_scheduler
.
config
.
prediction_type
}
"
)
loss
=
F
.
mse_loss
(
model_pred
.
float
(),
target
.
float
(),
reduction
=
"none"
).
mean
([
1
,
2
,
3
]).
mean
()
loss
=
F
.
mse_loss
(
model_pred
.
float
(),
target
.
float
(),
reduction
=
"mean"
)
accelerator
.
backward
(
loss
)
optimizer
.
step
()
...
...
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