-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b01c445
commit 3753d67
Showing
22 changed files
with
219 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,37 @@ | ||
using Flux, Tsunami | ||
using Documenter | ||
|
||
DocMeta.setdocmeta!(Tsunami, :DocTestSetup, | ||
:(using Tsunami, Flux); | ||
recursive = true) | ||
DocMeta.setdocmeta!(Tsunami, :DocTestSetup, :(using Tsunami, Flux); recursive = true) | ||
|
||
prettyurls = get(ENV, "CI", nothing) == "true" | ||
mathengine = MathJax3() | ||
sidebar_sitename = true | ||
assets = ["assets/flux.css"] | ||
|
||
makedocs(; | ||
modules = [Tsunami], | ||
doctest = true, | ||
checkdocs = :exports, | ||
format = Documenter.HTML(; mathengine, prettyurls, assets, sidebar_sitename), | ||
sitename = "Tsunami.jl", | ||
pages = [ | ||
"Get Started" => "index.md", | ||
|
||
"Guides" => "guides.md", | ||
|
||
"API Reference" => [ | ||
# This essentially collects docstrings, with a bit of introduction. | ||
"Callbacks" => "callbacks.md", | ||
"FluxModule" => "fluxmodule.md", | ||
"Hooks" => "hooks.md", | ||
"Logging" => "logging.md", | ||
"Trainer" => "trainer.md", | ||
"Utils" => "utils.md", | ||
], | ||
# "Tutorials" => [] # TODO These walk you through various tasks. It's fine if they overlap quite a lot. | ||
|
||
]) | ||
modules = [Tsunami], | ||
doctest = true, | ||
checkdocs = :exports, | ||
format = Documenter.HTML(; mathengine, prettyurls, assets, sidebar_sitename), | ||
sitename = "Tsunami.jl", | ||
pages = [ | ||
"Get Started" => "index.md", | ||
|
||
"Guides" => "guides.md", | ||
|
||
# "Tutorials" => [] # TODO These walk you through various tasks. It's fine if they overlap quite a lot. | ||
|
||
"API Reference" => [ | ||
# This essentially collects docstrings, with a bit of introduction. | ||
"Callbacks" => "api/callbacks.md", | ||
"FluxModule" => "api/fluxmodule.md", | ||
"Foil" => "api/foil.md", | ||
"Hooks" => "api/hooks.md", | ||
"Logging" => "api/logging.md", | ||
"Trainer" => "api/trainer.md", | ||
"Utils" => "api/utils.md", | ||
], | ||
] | ||
) | ||
|
||
deploydocs(repo = "github.com/CarloLucibello/Tsunami.jl.git") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
```@meta | ||
CollapsedDocStrings = true | ||
``` | ||
|
||
# FluxModule | ||
|
||
```@docs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Foil | ||
|
||
The [`Foil`](@ref) is a minimalistic version of the [`Trainer`](@ref) that allows to make only minimal changes to your Flux code while still obtaining many of the benefits of Tsunami. This is similar to what `Lighting Fabric` is to `PyTorch Lightning`. `Foil` also resembles HuggingFace's `accelerate` library. | ||
|
||
```@docs | ||
Foil | ||
Tsunami.setup | ||
Tsunami.setup_batch | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
```@meta | ||
CollapsedDocStrings = true | ||
``` | ||
|
||
# Logging | ||
|
||
```@docs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@testitem "Foil constructor" begin | ||
foil = Foil(accelerator=:cpu, precision=:f32, devices=nothing) | ||
@test foil isa Foil | ||
end | ||
|
||
@testitem "Tsunami.setup" setup=[TsunamiTest] begin | ||
using .TsunamiTest | ||
foil = Foil(accelerator=:cpu, precision=:f32, devices=nothing) | ||
model = Chain(Dense(28^2 => 512, relu), Dense(512 => 10)) | ||
opt_state = Flux.setup(AdamW(1e-3), model) | ||
model, opt_state = Tsunami.setup(foil, model, opt_state) | ||
@test model isa Chain | ||
@test opt_state.layers[1].weight isa Optimisers.Leaf{<:AdamW} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
|
||
@testitem "linear regression" setup=[TsunamiTest] begin | ||
using .TsunamiTest | ||
N = 1000 | ||
α = 0.5 | ||
λ = 1f-5 / round(Int, N * α) | ||
|
||
N = 1000 | ||
α = 0.5 | ||
λ = 1f-5 / round(Int, N * α) | ||
M = round(Int, N * α) | ||
teacher = LinearModel(N) | ||
X = randn(Float32, N, M) | ||
y = teacher(X) | ||
|
||
M = round(Int, N * α) | ||
teacher = LinearModel(N) | ||
X = randn(Float32, N, M) | ||
y = teacher(X) | ||
|
||
model = LinearModel(N; λ) | ||
@test model.W isa Matrix{Float32} | ||
@test size(model.W) == (1, N) | ||
|
||
trainer = SilentTrainer(max_epochs=1000, devices=[1]) | ||
fit_state = Tsunami.fit!(model, trainer, [(X, y)]) | ||
@test model.W isa Matrix{Float32} # by default precision is Float32 | ||
model = LinearModel(N; λ) | ||
@test model.W isa Matrix{Float32} | ||
@test size(model.W) == (1, N) | ||
trainer = SilentTrainer(max_epochs=1000, devices=[1]) | ||
fit_state = Tsunami.fit!(model, trainer, [(X, y)]) | ||
@test model.W isa Matrix{Float32} # by default precision is Float32 | ||
@test Flux.mse(model(X), y) < 1e-1 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.