Skip to content

Commit e828f4a

Browse files
fixed docstrings in inits
1 parent ba68c90 commit e828f4a

File tree

1 file changed

+49
-15
lines changed

1 file changed

+49
-15
lines changed

src/esn/esn_inits.jl

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ a range defined by `scaling`.
1313
- `T`: Type of the elements in the reservoir matrix.
1414
Default is `Float32`.
1515
- `dims`: Dimensions of the matrix. Should follow `res_size x in_size`.
16+
17+
# Keyword arguments
18+
1619
- `scaling`: A scaling factor to define the range of the uniform distribution.
1720
The matrix elements will be randomly chosen from the
1821
range `[-scaling, scaling]`. Defaults to `0.1`.
@@ -55,6 +58,9 @@ elements distributed uniformly within the range [-`scaling`, `scaling`] [^Lu2017
5558
- `T`: Type of the elements in the reservoir matrix.
5659
Default is `Float32`.
5760
- `dims`: Dimensions of the matrix. Should follow `res_size x in_size`.
61+
62+
# Keyword arguments
63+
5864
- `scaling`: The scaling factor for the weight distribution.
5965
Defaults to `0.1`.
6066
- `return_sparse`: flag for returning a `sparse` matrix.
@@ -106,6 +112,9 @@ Create an input layer for informed echo state networks [^Pathak2018].
106112
- `T`: Type of the elements in the reservoir matrix.
107113
Default is `Float32`.
108114
- `dims`: Dimensions of the matrix. Should follow `res_size x in_size`.
115+
116+
# Keyword arguments
117+
109118
- `scaling`: The scaling factor for the input matrix.
110119
Default is 0.1.
111120
- `model_in_size`: The size of the input model.
@@ -167,6 +176,9 @@ is randomly determined by the `sampling` chosen.
167176
- `T`: Type of the elements in the reservoir matrix.
168177
Default is `Float32`.
169178
- `dims`: Dimensions of the matrix. Should follow `res_size x in_size`.
179+
180+
# Keyword arguments
181+
170182
- `weight`: The weight used to fill the layer matrix. Default is 0.1.
171183
- `sampling_type`: The sampling parameters used to generate the input matrix.
172184
Default is `:bernoulli`.
@@ -282,7 +294,7 @@ function _create_irrational(irrational::Irrational, start::Int, res_size::Int,
282294
return T.(input_matrix)
283295
end
284296

285-
"""
297+
@doc raw"""
286298
chebyshev_mapping([rng], [T], dims...;
287299
amplitude=one(T), sine_divisor=one(T),
288300
chebyshev_parameter=one(T), return_sparse=true)
@@ -292,14 +304,15 @@ using a sine function and subsequent rows are iteratively generated
292304
via the Chebyshev mapping. The first row is defined as:
293305
294306
```math
295-
w(1, j) = amplitude * sin(j * π / (sine_divisor * n_cols))
307+
W[1, j] = \text{amplitude} \cdot \sin(j \cdot \pi / (\text{sine_divisor}
308+
\cdot \text{n_cols}))
296309
```
297310
298311
for j = 1, 2, …, n_cols (with n_cols typically equal to K+1, where K is the number of input layer neurons).
299312
Subsequent rows are generated by applying the mapping:
300313
301314
```math
302-
w(i+1, j) = cos(chebyshev_parameter * acos(w(i, j)))
315+
W[i+1, j] = \cos( \text{chebyshev_parameter} \cdot \acos(W[pi, j]))
303316
```
304317
305318
# Arguments
@@ -364,22 +377,23 @@ function chebyshev_mapping(rng::AbstractRNG, ::Type{T}, dims::Integer...;
364377
end
365378

366379
@doc raw"""
367-
logistic_mapping(rng::AbstractRNG, ::Type{T}, dims::Integer...;
368-
amplitude=0.3, sine_divisor=5.9, logistic_parameter = 3.7,
380+
logistic_mapping([rng], [T], dims...;
381+
amplitude=0.3, sine_divisor=5.9, logistic_parameter=3.7,
369382
return_sparse=true)
370383
371384
Generate an input weight matrix using a logistic mapping [^wang2022].The first
372385
row is initialized using a sine function:
373386
374387
```math
375-
W(1, j) = amplitude * sin(j * π / (sine_divisor * in_size))
388+
W[1, j] = \text{amplitude} \cdot \sin(j \cdot \pi /
389+
(\text{sine_divisor} \cdot in_size))
376390
```
377391
378392
for each input index `j`, with `in_size` being the number of columns provided in `dims`. Subsequent rows
379393
are generated recursively using the logistic map recurrence:
380394
381395
```math
382-
W(i+1, j) = logistic_parameter * W(i, j) * (1 - W(i, j))
396+
W[i+1, j] = \text{logistic_parameter} \cdot W(i, j) \cdot (1 - W[i, j])
383397
```
384398
385399
# Arguments
@@ -389,7 +403,8 @@ are generated recursively using the logistic map recurrence:
389403
Default is `Float32`.
390404
- `dims`: Dimensions of the matrix. Should follow `res_size x in_size`.
391405
392-
# keyword arguments
406+
# Keyword arguments
407+
393408
- `amplitude`: Scaling parameter used in the sine initialization of the
394409
first row. Default is 0.3.
395410
- `sine_divisor`: Parameter used to adjust the phase in the sine initialization.
@@ -452,14 +467,15 @@ as follows:
452467
- The first element of the chain is initialized using a sine function:
453468
454469
```math
455-
W(1,j) = amplitude * sin( (j * π) / (factor * n * sine_divisor) )
470+
W[1,j] = \text{amplitude} \cdot \sin( (j \cdot \pi) /
471+
(\text{factor} \cdot \text{n} \cdot \text{sine_divisor}) )
456472
```
457473
where `j` is the index corresponding to the input and `n` is the number of inputs.
458474
459475
- Subsequent elements are recursively computed using the logistic mapping:
460476
461477
```math
462-
W(i+1,j) = logistic_parameter * W(i,j) * (1 - W(i,j))
478+
W[i+1,j] = \text{logistic_parameter} \cdot W[i,j] \cdot (1 - W[i,j])
463479
```
464480
465481
The resulting matrix has dimensions `(factor * in_size) x in_size`, where
@@ -474,7 +490,8 @@ the number of rows is overridden.
474490
Default is `Float32`.
475491
- `dims`: Dimensions of the matrix. Should follow `res_size x in_size`.
476492
477-
# keyword arguments
493+
# Keyword arguments
494+
478495
- `factor`: The number of logistic map iterations (chain length) per input,
479496
determining the number of rows per input.
480497
- `amplitude`: Scaling parameter A for the sine-based initialization of
@@ -563,6 +580,8 @@ and scaled spectral radius according to `radius`.
563580
- `T`: Type of the elements in the reservoir matrix.
564581
Default is `Float32`.
565582
- `dims`: Dimensions of the reservoir matrix.
583+
# Keyword arguments
584+
566585
- `radius`: The desired spectral radius of the reservoir.
567586
Defaults to 1.0.
568587
- `sparsity`: The sparsity level of the reservoir matrix,
@@ -609,6 +628,9 @@ Create and return a delay line reservoir matrix [^Rodan2010].
609628
- `T`: Type of the elements in the reservoir matrix.
610629
Default is `Float32`.
611630
- `dims`: Dimensions of the reservoir matrix.
631+
632+
# Keyword arguments
633+
612634
- `weight`: Determines the value of all connections in the reservoir.
613635
Default is 0.1.
614636
- `return_sparse`: flag for returning a `sparse` matrix.
@@ -652,7 +674,7 @@ end
652674

653675
"""
654676
delay_line_backward([rng], [T], dims...;
655-
weight = 0.1, fb_weight = 0.2, return_sparse=true)
677+
weight=0.1, fb_weight=0.2, return_sparse=true)
656678
657679
Create a delay line backward reservoir with the specified by `dims` and weights.
658680
Creates a matrix with backward connections as described in [^Rodan2010].
@@ -664,6 +686,9 @@ Creates a matrix with backward connections as described in [^Rodan2010].
664686
- `T`: Type of the elements in the reservoir matrix.
665687
Default is `Float32`.
666688
- `dims`: Dimensions of the reservoir matrix.
689+
690+
# Keyword arguments
691+
667692
- `weight`: The weight determines the absolute value of
668693
forward connections in the reservoir. Default is 0.1
669694
- `fb_weight`: Determines the absolute value of backward connections
@@ -709,7 +734,7 @@ end
709734

710735
"""
711736
cycle_jumps([rng], [T], dims...;
712-
cycle_weight = 0.1, jump_weight = 0.1, jump_size = 3, return_sparse=true)
737+
cycle_weight=0.1, jump_weight=0.1, jump_size=3, return_sparse=true)
713738
714739
Create a cycle jumps reservoir with the specified dimensions,
715740
cycle weight, jump weight, and jump size.
@@ -721,6 +746,9 @@ cycle weight, jump weight, and jump size.
721746
- `T`: Type of the elements in the reservoir matrix.
722747
Default is `Float32`.
723748
- `dims`: Dimensions of the reservoir matrix.
749+
750+
# Keyword arguments
751+
724752
- `cycle_weight`: The weight of cycle connections.
725753
Default is 0.1.
726754
- `jump_weight`: The weight of jump connections.
@@ -779,7 +807,7 @@ end
779807

780808
"""
781809
simple_cycle([rng], [T], dims...;
782-
weight = 0.1, return_sparse=true)
810+
weight=0.1, return_sparse=true)
783811
784812
Create a simple cycle reservoir with the specified dimensions and weight.
785813
@@ -789,6 +817,9 @@ Create a simple cycle reservoir with the specified dimensions and weight.
789817
from WeightInitializers.
790818
- `T`: Type of the elements in the reservoir matrix. Default is `Float32`.
791819
- `dims`: Dimensions of the reservoir matrix.
820+
821+
# Keyword arguments
822+
792823
- `weight`: Weight of the connections in the reservoir matrix.
793824
Default is 0.1.
794825
- `return_sparse`: flag for returning a `sparse` matrix.
@@ -831,7 +862,7 @@ end
831862

832863
"""
833864
pseudo_svd([rng], [T], dims...;
834-
max_value=1.0, sparsity=0.1, sorted = true, reverse_sort = false,
865+
max_value=1.0, sparsity=0.1, sorted=true, reverse_sort=false,
835866
return_sparse=true)
836867
837868
Returns an initializer to build a sparse reservoir matrix with the given
@@ -844,6 +875,9 @@ Returns an initializer to build a sparse reservoir matrix with the given
844875
- `T`: Type of the elements in the reservoir matrix.
845876
Default is `Float32`.
846877
- `dims`: Dimensions of the reservoir matrix.
878+
879+
# Keyword arguments
880+
847881
- `max_value`: The maximum absolute value of elements in the matrix.
848882
Default is 1.0
849883
- `sparsity`: The desired sparsity level of the reservoir matrix.

0 commit comments

Comments
 (0)