Skip to main content

ncps_rust/
lib.rs

1//! # NCPS - Neural Circuit Policies (Rust)
2//!
3//! Port of the Python NCPS library to Rust using the Burn framework.
4//!
5//! ## Features
6//!
7//! - **LTC**: Liquid Time-Constant RNN cells with ODE-based dynamics
8//! - **CfC**: Closed-form Continuous-time cells (3 modes: default, pure, no_gate)
9//! - **NCP**: Neural Circuit Policy wiring (biologically-inspired sparse connectivity)
10//! - **Sparsity Masks**: Wiring adjacency properly enforced in forward passes
11//! - **Input/Output Mapping**: Affine, Linear, or pass-through modes
12//! - **Mixed Memory**: LSTM augmentation for long-term dependencies
13//!
14//! ## Quick Start
15//!
16//! ```rust
17//! use ncps::prelude::*;
18//!
19//! // Create a wiring configuration
20//! let mut wiring = AutoNCP::new(32, 8, 0.5, 22222);
21//! wiring.build(16); // 16 input features
22//!
23//! assert_eq!(wiring.units(), 32);
24//! assert_eq!(wiring.output_dim(), Some(8));
25//! ```
26//!
27//! ## Cell-level Usage
28//!
29//! For direct cell access (single timestep processing):
30//!
31//! ```ignore
32//! use ncps::cells::{LTCCell, MappingMode};
33//! use ncps::wirings::FullyConnected;
34//!
35//! let wiring = FullyConnected::new(32, Some(8), 1234, true);
36//! let cell = LTCCell::<Backend>::new(&wiring, Some(16), &device)
37//!     .with_input_mapping(MappingMode::Affine, &device);
38//! ```
39
40pub mod activation;
41pub mod cells;
42pub mod rnn;
43pub mod wirings;
44
45pub mod prelude {
46    pub use crate::activation::LeCun;
47    pub use crate::cells::{CfCCell, CfcMode, LSTMCell, LTCCell, MappingMode};
48    pub use crate::rnn::{CfC, LTC};
49    pub use crate::wirings::{AutoNCP, FullyConnected, NCP, Random, Wiring};
50}