Skip to content

Commit a79dd1a

Browse files
Merge pull request #229 from SciML/fm/docs
Small docstring fixes
2 parents 655cac4 + 19e4e7f commit a79dd1a

File tree

5 files changed

+66
-29
lines changed

5 files changed

+66
-29
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# ReservoirComputing.jl
1+
<p align="center">
2+
<img width="400px" src="docs/src/assets/logo.png"/>
3+
</p>
4+
5+
<div align="center">
26

37
[![Join the chat at https://julialang.zulipchat.com #sciml-bridged](https://img.shields.io/static/v1?label=Zulip&message=chat&color=9558b2&labelColor=389826)](https://julialang.zulipchat.com/#narrow/stream/279055-sciml-bridged)
48
[![Global Docs](https://img.shields.io/badge/docs-SciML-blue.svg)](https://docs.sciml.ai/ReservoirComputing/stable/)
@@ -11,8 +15,9 @@
1115
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor%27s%20Guide-blueviolet)](https://github.com/SciML/ColPrac)
1216
[![SciML Code Style](https://img.shields.io/static/v1?label=code%20style&message=SciML&color=9558b2&labelColor=389826)](https://github.com/SciML/SciMLStyle)
1317

14-
![rc_full_logo_large_white_cropped](https://user-images.githubusercontent.com/10376688/144242116-8243f58a-5ac6-4e0e-88d5-3409f00e20b4.png)
18+
</div>
1519

20+
# ReservoirComputing.jl
1621
ReservoirComputing.jl provides an efficient, modular and easy to use implementation of Reservoir Computing models such as Echo State Networks (ESNs). For information on using this package please refer to the [stable documentation](https://docs.sciml.ai/ReservoirComputing/stable/). Use the [in-development documentation](https://docs.sciml.ai/ReservoirComputing/dev/) to take a look at at not yet released features.
1722

1823
## Quick Example

docs/src/esn_tutorials/change_layers.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ weights = init(rng, dims...)
77
#rng is optional
88
weights = init(dims...)
99
```
10+
1011
Additional keywords can be added when needed:
12+
1113
```julia
1214
weights_init = init(rng; kwargs...)
1315
weights = weights_init(rng, dims...)
@@ -32,26 +34,27 @@ predict_len = 2000
3234
ds = Systems.henon()
3335
traj, t = trajectory(ds, 7000)
3436
data = Matrix(traj)'
35-
data = (data .-0.5) .* 2
37+
data = (data .- 0.5) .* 2
3638
shift = 200
3739
38-
training_input = data[:, shift:shift+train_len-1]
39-
training_target = data[:, shift+1:shift+train_len]
40-
testing_input = data[:,shift+train_len:shift+train_len+predict_len-1]
41-
testing_target = data[:,shift+train_len+1:shift+train_len+predict_len]
40+
training_input = data[:, shift:(shift + train_len - 1)]
41+
training_target = data[:, (shift + 1):(shift + train_len)]
42+
testing_input = data[:, (shift + train_len):(shift + train_len + predict_len - 1)]
43+
testing_target = data[:, (shift + train_len + 1):(shift + train_len + predict_len)]
4244
```
45+
4346
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.
4447

4548
```@example minesn
4649
using ReservoirComputing, StatsBase
4750
4851
res_size = 300
49-
input_layer = [minimal_init(; weight = 0.85, sampling_type=:irrational),
50-
minimal_init(; weight = 0.95, sampling_type=:irrational)]
51-
reservoirs = [simple_cycle(; weight=0.7),
52-
cycle_jumps(; cycle_weight=0.7, jump_weight=0.2, jump_size=5)]
52+
input_layer = [minimal_init(; weight = 0.85, sampling_type = :irrational),
53+
minimal_init(; weight = 0.95, sampling_type = :irrational)]
54+
reservoirs = [simple_cycle(; weight = 0.7),
55+
cycle_jumps(; cycle_weight = 0.7, jump_weight = 0.2, jump_size = 5)]
5356
54-
for i=1:length(reservoirs)
57+
for i in 1:length(reservoirs)
5558
esn = ESN(training_input, 2, res_size;
5659
input_layer = input_layer[i],
5760
reservoir = reservoirs[i])
@@ -60,9 +63,10 @@ for i=1:length(reservoirs)
6063
println(msd(testing_target, output))
6164
end
6265
```
66+
6367
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.
6468

6569
## Bibliography
66-
[^rodan2012]: Rodan, Ali, and Peter Tiňo. “Simple deterministically constructed cycle reservoirs with regular jumps.” Neural computation 24.7 (2012): 1822-1852.
6770

68-
[^rodan2010]: Rodan, Ali, and Peter Tiňo. “Minimum complexity echo state network.” IEEE transactions on neural networks 22.1 (2010): 131-144.
71+
[^rodan2012]: Rodan, Ali, and Peter Tiňo. “Simple deterministically constructed cycle reservoirs with regular jumps.” Neural computation 24.7 (2012): 1822-1852.
72+
[^rodan2010]: Rodan, Ali, and Peter Tiňo. “Minimum complexity echo state network.” IEEE transactions on neural networks 22.1 (2010): 131-144.

src/ReservoirComputing.jl

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,25 @@ end
4545
"""
4646
Generative(prediction_len)
4747
48-
This prediction methodology allows the models to produce an autonomous prediction, feeding the prediction into itself to generate the next step.
49-
The only parameter needed is the number of steps for the prediction.
48+
A prediction strategy that enables models to generate autonomous multi-step
49+
forecasts by recursively feeding their own outputs back as inputs for
50+
subsequent prediction steps.
51+
52+
# Parameters
53+
54+
- `prediction_len::Int`: The number of future steps to predict.
55+
56+
# Description
57+
58+
The `Generative` prediction method allows a model to perform multi-step
59+
forecasting by using its own previous predictions as inputs for future predictions.
60+
This approach is especially useful in time series analysis, where each prediction
61+
depends on the preceding data points.
62+
63+
At each step, the model takes the current input, generates a prediction,
64+
and then incorporates that prediction into the input for the next step.
65+
This recursive process continues until the specified
66+
number of prediction steps (`prediction_len`) is reached.
5067
"""
5168
struct Generative{T} <: AbstractPrediction
5269
prediction_len::T
@@ -60,7 +77,27 @@ end
6077
"""
6178
Predictive(prediction_data)
6279
63-
Given a set of labels as `prediction_data`, this method of prediction will return the corresponding labels in a standard Machine Learning fashion.
80+
A prediction strategy for supervised learning tasks,
81+
where a model predicts labels based on a provided set
82+
of input features (`prediction_data`).
83+
84+
# Parameters
85+
86+
- `prediction_data`: The input data used for prediction, typically structured as a matrix
87+
where each column represents a sample, and each row represents a feature.
88+
89+
# Description
90+
91+
The `Predictive` prediction method is a standard approach
92+
in supervised machine learning tasks. It uses the provided input data
93+
(`prediction_data`) to produce corresponding labels or outputs based
94+
on the learned relationships in the model. Unlike generative prediction,
95+
this method does not recursively feed predictions into the model;
96+
instead, it operates on fixed input data to produce a single batch of predictions.
97+
98+
This method is suitable for tasks like classification,
99+
regression, or other use cases where the input features
100+
and the number of steps are predefined.
64101
"""
65102
function Predictive(prediction_data)
66103
prediction_len = size(prediction_data, 2)

src/esn/deepesn.jl

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ temporal features.
5555
- `matrix_type`: The type of matrix used for storing the training data.
5656
Default is inferred from `train_data`.
5757
58-
# Returns
59-
60-
- A `DeepESN` instance configured according to the provided parameters
61-
and suitable for further training and prediction tasks.
62-
6358
# Example
6459
6560
```julia
@@ -73,10 +68,6 @@ deepESN = DeepESN(train_data, 10, 100, depth = 3, washout = 100)
7368
train(deepESN, target_data)
7469
prediction = predict(deepESN, new_data)
7570
```
76-
77-
The DeepESN model is ideal for tasks requiring the processing of sequences with
78-
complex temporal dependencies, benefiting from the multiple reservoirs to capture
79-
different levels of abstraction and temporal dynamics.
8071
"""
8172
function DeepESN(train_data,
8273
in_size::Int,

src/esn/esn.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ Creates an Echo State Network (ESN) using specified parameters and training data
2121
2222
- `train_data`: Matrix of training data (columns as time steps, rows as features).
2323
- `variation`: Variation of ESN (default: `Default()`).
24-
- `input_layer`: Input layer of ESN (default: `DenseLayer()`).
25-
- `reservoir`: Reservoir of the ESN (default: `RandSparseReservoir(100)`).
26-
- `bias`: Bias vector for each time step (default: `NullLayer()`).
24+
- `input_layer`: Input layer of ESN.
25+
- `reservoir`: Reservoir of the ESN.
26+
- `bias`: Bias vector for each time step.
2727
- `reservoir_driver`: Mechanism for evolving reservoir states (default: `RNN()`).
2828
- `nla_type`: Non-linear activation type (default: `NLADefault()`).
2929
- `states_type`: Format for storing states (default: `StandardStates()`).

0 commit comments

Comments
 (0)