Skip to content

Commit

Permalink
Merge pull request #143 from SciML/fm/example
Browse files Browse the repository at this point in the history
Docs work
  • Loading branch information
ChrisRackauckas authored Dec 23, 2022
2 parents 70bf210 + 4e328cd commit 429bbd0
Show file tree
Hide file tree
Showing 23 changed files with 10,210 additions and 165 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ReservoirComputing.jl provides an efficient, modular and easy to use implementat
## Quick Example

To illustrate the workflow of this library we will showcase how it is possible to train an ESN to learn the dynamics of the Lorenz system. As a first step we will need to gather the data. For the `Generative` prediction we need the target data to be one step ahead of the training data:

```julia
using ReservoirComputing, OrdinaryDiffEq

Expand Down
9 changes: 9 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
[deps]
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
CellularAutomata = "878138dc-5b27-11ea-1a71-cb95d38d6b29"
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
DynamicalSystems = "61744808-ddfa-5f27-97ff-6e42cc95d634"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
ReservoirComputing = "7c2d2b1e-3dd4-11ea-355a-8f6a8116e294"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"

[compat]
Documenter = "0.27"
Expand Down
10 changes: 10 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@ using Documenter, ReservoirComputing
cp("./docs/Manifest.toml", "./docs/src/assets/Manifest.toml", force = true)
cp("./docs/Project.toml", "./docs/src/assets/Project.toml", force = true)

ENV["PLOTS_TEST"] = "true"
ENV["GKSwstype"] = "100"
include("pages.jl")

makedocs(modules = [ReservoirComputing],
clean = true, doctest = false,
sitename = "ReservoirComputing.jl",
strict = [
:doctest,
:linkcheck,
:parse_error,
:example_block,
# Other available options are
# :autodocs_block, :cross_references, :docs_block, :eval_block, :example_block, :footnote, :meta_block, :missing_docs, :setup_block
],
format = Documenter.HTML(analytics = "UA-90474609-3",
assets = ["assets/favicon.ico"],
canonical = "https://docs.sciml.ai/ReservoirComputing/stable/"),
Expand Down
2 changes: 1 addition & 1 deletion docs/pages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pages = [
"Altering States" => "general/states_variation.md",
"Generative vs Predictive" => "general/predictive_generative.md"],
"Echo State Network Tutorials" => Any["Lorenz System Forecasting" => "esn_tutorials/lorenz_basic.md",
"Mackey-Glass Forecasting on GPU" => "esn_tutorials/mackeyglass_basic.md",
#"Mackey-Glass Forecasting on GPU" => "esn_tutorials/mackeyglass_basic.md",
"Using Different Layers" => "esn_tutorials/change_layers.md",
"Using Different Reservoir Drivers" => "esn_tutorials/different_drivers.md",
#"Using Different Training Methods" => "esn_tutorials/different_training.md",
Expand Down
4 changes: 0 additions & 4 deletions docs/src/api/esn_drivers.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,3 @@ The ```GRU``` driver also provides the user the choice of the possible variant:
```
Please refer to the original papers for more detail about these architectures.

The states are created using the following function
```@docs
create_states
```
4 changes: 1 addition & 3 deletions docs/src/api/training.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
```

## Gaussian Regression
```@docs
GaussianProcess
```
Currently (v0.9) unavailable.

## Support Vector Regression
Support vector Regression is possible using a direct call to [LIBSVM](https://github.com/JuliaML/LIBSVM.jl) regression methods. Instead of a wrapper please refer to the use of ```LIBSVM.AbstractSVR``` in the original library.
12 changes: 4 additions & 8 deletions docs/src/esn_tutorials/change_layers.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ end
Using [^1] and [^2] as references this section will provide an example on how to change both the input layer and the reservoir for ESNs. The full script for this example can be found [here](https://github.com/MartinuzziFrancesco/reservoir-computing-examples/blob/main/change_layers/layers.jl). This example was run on Julia v1.7.2.

The task for this example will be the one step ahead prediction of the Henon map. To obtain the data one can leverage the package [DynamicalSystems.jl](https://juliadynamics.github.io/DynamicalSystems.jl/dev/). The data is scaled to be between -1 and 1.
```julia
```@example mesn
using DynamicalSystems
train_len = 3000
predict_len = 2000
Expand All @@ -62,7 +62,7 @@ testing_target = data[:,shift+train_len+1:shift+train_len+predict_len]

Now it is possible to define the input layers and reservoirs we want to compare and run the comparison in a simple for loop. The accuracy will be tested using the mean squared deviation `msd` from [StatsBase](https://juliastats.org/StatsBase.jl/stable/).

```julia
```@example mesn
using ReservoirComputing, StatsBase
res_size = 300
Expand All @@ -72,17 +72,13 @@ reservoirs = [SimpleCycleReservoir(res_size, 0.7),
for i=1:length(reservoirs)
esn = ESN(training_input;
input_init = input_layer[i],
reservoir_init = reservoirs[i])
input_layer = input_layer[i],
reservoir = reservoirs[i])
wout = train(esn, training_target, StandardRidge(0.001))
output = esn(Predictive(testing_input), wout)
println(msd(testing_target, output))
end
```
```
0.003402709948526517
0.0034463857980330612
```
As it is possible to see, changing layers in ESN models is straightforward. Be sure to check the API documentation for a full list of reservoir and layers.


Expand Down
Loading

0 comments on commit 429bbd0

Please sign in to comment.