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
diffusers
Commits
1dc856e5
Commit
1dc856e5
authored
Apr 06, 2023
by
William Berman
Committed by
Will Berman
Apr 09, 2023
Browse files
ddpm scheduler variance fixes
parent
2cbdc586
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
src/diffusers/schedulers/scheduling_ddpm.py
src/diffusers/schedulers/scheduling_ddpm.py
+4
-3
No files found.
src/diffusers/schedulers/scheduling_ddpm.py
View file @
1dc856e5
...
@@ -214,16 +214,17 @@ class DDPMScheduler(SchedulerMixin, ConfigMixin):
...
@@ -214,16 +214,17 @@ class DDPMScheduler(SchedulerMixin, ConfigMixin):
# and sample from it to get previous sample
# and sample from it to get previous sample
# x_{t-1} ~ N(pred_prev_sample, variance) == add variance to pred_sample
# x_{t-1} ~ N(pred_prev_sample, variance) == add variance to pred_sample
variance
=
(
1
-
alpha_prod_t_prev
)
/
(
1
-
alpha_prod_t
)
*
current_beta_t
variance
=
(
1
-
alpha_prod_t_prev
)
/
(
1
-
alpha_prod_t
)
*
current_beta_t
variance
=
torch
.
clamp
(
variance
,
min
=
1e-20
)
if
variance_type
is
None
:
if
variance_type
is
None
:
variance_type
=
self
.
config
.
variance_type
variance_type
=
self
.
config
.
variance_type
# hacks - were probably added for training stability
# hacks - were probably added for training stability
if
variance_type
==
"fixed_small"
:
if
variance_type
==
"fixed_small"
:
variance
=
torch
.
clamp
(
variance
,
min
=
1e-20
)
variance
=
variance
# for rl-diffuser https://arxiv.org/abs/2205.09991
# for rl-diffuser https://arxiv.org/abs/2205.09991
elif
variance_type
==
"fixed_small_log"
:
elif
variance_type
==
"fixed_small_log"
:
variance
=
torch
.
log
(
torch
.
clamp
(
variance
,
min
=
1e-20
)
)
variance
=
torch
.
log
(
variance
,
min
=
1e-20
)
variance
=
torch
.
exp
(
0.5
*
variance
)
variance
=
torch
.
exp
(
0.5
*
variance
)
elif
variance_type
==
"fixed_large"
:
elif
variance_type
==
"fixed_large"
:
variance
=
current_beta_t
variance
=
current_beta_t
...
@@ -234,7 +235,7 @@ class DDPMScheduler(SchedulerMixin, ConfigMixin):
...
@@ -234,7 +235,7 @@ class DDPMScheduler(SchedulerMixin, ConfigMixin):
return
predicted_variance
return
predicted_variance
elif
variance_type
==
"learned_range"
:
elif
variance_type
==
"learned_range"
:
min_log
=
torch
.
log
(
variance
)
min_log
=
torch
.
log
(
variance
)
max_log
=
torch
.
log
(
self
.
betas
[
t
]
)
max_log
=
torch
.
log
(
current_beta_t
)
frac
=
(
predicted_variance
+
1
)
/
2
frac
=
(
predicted_variance
+
1
)
/
2
variance
=
frac
*
max_log
+
(
1
-
frac
)
*
min_log
variance
=
frac
*
max_log
+
(
1
-
frac
)
*
min_log
...
...
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