mirror of
https://github.com/Laurent2916/Diffusers.jl.git
synced 2024-09-07 21:49:58 +00:00
📝 (beta_schedules) prettier β and α̅ plots
This commit is contained in:
parent
a25e74a62a
commit
b931b5ceb5
|
@ -1,5 +1,6 @@
|
|||
[deps]
|
||||
Diffusers = "90edb7a8-79d7-49b2-b6b1-9322c3fdead8"
|
||||
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
|
||||
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
|
||||
PlotlyJS = "f0f68f2c-4968-5e81-91da-67840de0976a"
|
||||
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
|
||||
|
|
|
@ -1,32 +1,105 @@
|
|||
```@eval
|
||||
using Diffusers.BetaSchedules
|
||||
using Plots
|
||||
plotlyjs()
|
||||
using LaTeXStrings
|
||||
using PlotlyJS
|
||||
|
||||
T = 1000
|
||||
linear = linear_beta_schedule(T)
|
||||
scaled_linear = scaled_linear_beta_schedule(T)
|
||||
cosine = cosine_beta_schedule(T)
|
||||
sigmoid = sigmoid_beta_schedule(T)
|
||||
|
||||
plot(
|
||||
[linear, scaled_linear, cosine, sigmoid],
|
||||
label=["linear" "scaled_linear" "cosine" "sigmoid"],
|
||||
xlabel="t",
|
||||
ylabel="β",
|
||||
title="Beta schedules",
|
||||
legend=:topleft,
|
||||
yscale=:log10,
|
||||
β_linear = linear_beta_schedule(T)
|
||||
β_scaled_linear = scaled_linear_beta_schedule(T)
|
||||
β_cosine = cosine_beta_schedule(T)
|
||||
β_sigmoid = sigmoid_beta_schedule(T)
|
||||
|
||||
α̅_linear = cumprod(1 .- β_linear)
|
||||
α̅_scaled_linear = cumprod(1 .- β_scaled_linear)
|
||||
α̅_cosine = cumprod(1 .- β_cosine)
|
||||
α̅_sigmoid = cumprod(1 .- β_sigmoid)
|
||||
|
||||
p1 = plot(
|
||||
[
|
||||
scatter(y=β_linear, name="Linear"),
|
||||
scatter(y=β_scaled_linear, name="Scaled linear"),
|
||||
scatter(y=β_cosine, name="Cosine"),
|
||||
scatter(y=β_sigmoid, name="Sigmoid"),
|
||||
],
|
||||
Layout(
|
||||
updatemenus=[
|
||||
attr(
|
||||
type="buttons",
|
||||
active=1,
|
||||
buttons=[
|
||||
attr(
|
||||
label="Linear",
|
||||
method="relayout",
|
||||
args=["yaxis.type", "linear"],
|
||||
),
|
||||
attr(
|
||||
label="Log",
|
||||
method="relayout",
|
||||
args=["yaxis.type", "log"],
|
||||
),
|
||||
]
|
||||
),
|
||||
],
|
||||
title="Beta schedules",
|
||||
xaxis=attr(
|
||||
title=L"$t$",
|
||||
),
|
||||
yaxis=attr(
|
||||
type="log",
|
||||
title=L"\beta",
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
savefig("fig_beta_schedules.html")
|
||||
savefig(p1, "fig_beta_schedules.html")
|
||||
|
||||
p2 = plot(
|
||||
[
|
||||
scatter(y=α̅_linear, name="Linear"),
|
||||
scatter(y=α̅_scaled_linear, name="Scaled linear"),
|
||||
scatter(y=α̅_cosine, name="Cosine"),
|
||||
scatter(y=α̅_sigmoid, name="Sigmoid"),
|
||||
],
|
||||
Layout(
|
||||
updatemenus=[
|
||||
attr(
|
||||
type="buttons",
|
||||
buttons=[
|
||||
attr(
|
||||
label="Linear",
|
||||
method="relayout",
|
||||
args=["yaxis.type", "linear"],
|
||||
),
|
||||
attr(
|
||||
label="Log",
|
||||
method="relayout",
|
||||
args=["yaxis.type", "log"],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
title="Cumulative alpha schedules",
|
||||
xaxis=attr(
|
||||
title=L"$t$",
|
||||
),
|
||||
yaxis=attr(
|
||||
title=L"\overline\alpha",
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
savefig(p2, "fig_alpha_bar_schedules.html")
|
||||
|
||||
nothing
|
||||
```
|
||||
|
||||
```@raw html
|
||||
<object type="text/html" data="fig_beta_schedules.html" style="width:100%;height:420px;"></object>
|
||||
<object type="text/html" data="fig_alpha_bar_schedules.html" style="width:100%;height:420px;"></object>
|
||||
```
|
||||
|
||||
|
||||
```@autodocs
|
||||
Modules = [Diffusers.BetaSchedules]
|
||||
```
|
||||
|
|
Loading…
Reference in a new issue