mirror of
https://github.com/Laurent2916/Diffusers.jl.git
synced 2024-09-18 18:45:28 +00:00
📝 (beta_schedules) prettier β and α̅ plots
This commit is contained in:
parent
a25e74a62a
commit
b931b5ceb5
|
@ -1,5 +1,6 @@
|
||||||
[deps]
|
[deps]
|
||||||
Diffusers = "90edb7a8-79d7-49b2-b6b1-9322c3fdead8"
|
Diffusers = "90edb7a8-79d7-49b2-b6b1-9322c3fdead8"
|
||||||
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
|
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
|
||||||
|
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
|
||||||
PlotlyJS = "f0f68f2c-4968-5e81-91da-67840de0976a"
|
PlotlyJS = "f0f68f2c-4968-5e81-91da-67840de0976a"
|
||||||
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
|
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
|
||||||
|
|
|
@ -1,32 +1,105 @@
|
||||||
```@eval
|
```@eval
|
||||||
using Diffusers.BetaSchedules
|
using Diffusers.BetaSchedules
|
||||||
using Plots
|
using LaTeXStrings
|
||||||
plotlyjs()
|
using PlotlyJS
|
||||||
|
|
||||||
T = 1000
|
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 = linear_beta_schedule(T)
|
||||||
[linear, scaled_linear, cosine, sigmoid],
|
β_scaled_linear = scaled_linear_beta_schedule(T)
|
||||||
label=["linear" "scaled_linear" "cosine" "sigmoid"],
|
β_cosine = cosine_beta_schedule(T)
|
||||||
xlabel="t",
|
β_sigmoid = sigmoid_beta_schedule(T)
|
||||||
ylabel="β",
|
|
||||||
title="Beta schedules",
|
α̅_linear = cumprod(1 .- β_linear)
|
||||||
legend=:topleft,
|
α̅_scaled_linear = cumprod(1 .- β_scaled_linear)
|
||||||
yscale=:log10,
|
α̅_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
|
nothing
|
||||||
```
|
```
|
||||||
|
|
||||||
```@raw html
|
```@raw html
|
||||||
<object type="text/html" data="fig_beta_schedules.html" style="width:100%;height:420px;"></object>
|
<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
|
```@autodocs
|
||||||
Modules = [Diffusers.BetaSchedules]
|
Modules = [Diffusers.BetaSchedules]
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in a new issue