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
renzhc
diffusers_dcu
Commits
14f4af8f
Unverified
Commit
14f4af8f
authored
Oct 03, 2022
by
Suraj Patil
Committed by
GitHub
Oct 03, 2022
Browse files
[dreambooth] fix applying clip_grad_norm_ (#686)
fix applying clip grad norm
parent
2558977b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
1 deletion
+2
-1
examples/dreambooth/train_dreambooth.py
examples/dreambooth/train_dreambooth.py
+2
-1
No files found.
examples/dreambooth/train_dreambooth.py
View file @
14f4af8f
...
@@ -566,7 +566,8 @@ def main():
...
@@ -566,7 +566,8 @@ def main():
loss
=
F
.
mse_loss
(
noise_pred
,
noise
,
reduction
=
"none"
).
mean
([
1
,
2
,
3
]).
mean
()
loss
=
F
.
mse_loss
(
noise_pred
,
noise
,
reduction
=
"none"
).
mean
([
1
,
2
,
3
]).
mean
()
accelerator
.
backward
(
loss
)
accelerator
.
backward
(
loss
)
accelerator
.
clip_grad_norm_
(
unet
.
parameters
(),
args
.
max_grad_norm
)
if
accelerator
.
sync_gradients
:
accelerator
.
clip_grad_norm_
(
unet
.
parameters
(),
args
.
max_grad_norm
)
optimizer
.
step
()
optimizer
.
step
()
lr_scheduler
.
step
()
lr_scheduler
.
step
()
optimizer
.
zero_grad
()
optimizer
.
zero_grad
()
...
...
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