reservoir_train/lib.rs
1#![cfg_attr(not(feature = "std"), no_std)]
2
3//! Training utilities for Echo State Networks (ESN).
4//!
5//! `reservoir-train` provides training-time components for Echo State Networks:
6//! - ridge / lasso solvers for linear readouts
7//! - an [`ESNBuilder`] for quickly assembling common ESN configurations
8//! - (optional, `std`) static code generation for embedded inference models
9//!
10//! This crate pairs with [`reservoir-infer`] (inference-time reservoirs/readouts).
11//!
12//! # Features
13//! - `std` (default): Enables `std` and code generation utilities.
14//! - `libm`: Enables `libm`-backed math for `no_std` targets (also affects dependencies).
15//!
16//! # High-level workflow
17//! 1. Build an ESN (dense or sparse) with [`ESNBuilder`]
18//! 2. Fit the readout using [`ESNFitRidge::fit`] or [`ESNFitLasso::fit_lasso`]
19//! 3. Run inference using the same model (`predict`), or export weights for deployment.
20//!
21//! # Examples
22//! See the `examples/` directory:
23//! - `esn_henon.rs`
24//! - `esn_mackey_glass.rs`
25//! - `esn_narma.rs`
26
27#[cfg(feature = "std")]
28extern crate std;
29
30extern crate alloc;
31
32#[cfg(feature = "std")]
33pub mod codegen;
34pub mod esn;
35pub mod float;
36pub mod trainer;
37
38#[cfg(feature = "std")]
39pub use codegen::StaticModelGenerator;
40pub use esn::{ESNBuilder, ESNFitLasso, ESNFitRidge};
41
42/// Re-export `reservoir-infer` so downstream users can refer to a single crate.
43///
44/// This is convenient when `reservoir-train` is used as the training entry point.
45pub use reservoir_infer;
46
47pub use reservoir_infer::{DenseReservoir, EchoStateNetwork, LassoReadout, RidgeReadout};
48pub use trainer::RidgeTrainer;
49
50/// RNG type used internally by [`ESNBuilder`].
51///
52/// - With `std`: [`rand::rngs::StdRng`]
53/// - Without `std`: [`rand::rngs::SmallRng`]
54#[cfg(feature = "std")]
55pub type RngType = rand::rngs::StdRng;
56
57#[cfg(not(feature = "std"))]
58pub type RngType = rand::rngs::SmallRng;