cge/
lib.rs

1//! A library for creating, using, and modifying artificial neural networks using the [Common
2//! Genetic Encoding (CGE)][0]. See [`const_cge`][1] for a similar library geared towards embedded
3//! environments and performance-critical use cases. For the creation of CGE-compatible neural
4//! networks, see the [`eant2`][2] library.
5//!
6//! # Quick Start
7//!
8//! To load and use an existing neural network from a file:
9//!
10//! ```no_run
11//! use cge::{Network, WithRecurrentState};
12//!
13//! // `extra` is any user-defined data stored alongside the network
14//! let (mut network, metadata, extra) =
15//!     Network::<f64>::load_file::<(), _>("network.cge", WithRecurrentState(true)).unwrap();
16//!
17//! println!("description: {:?}", metadata.description);
18//! println!("num inputs, outputs: {}, {}", network.num_inputs(), network.num_outputs());
19//! println!("{:?}", network.evaluate(&[1.0, 2.0]).unwrap());
20//!
21//! network.clear_state();
22//!
23//! println!("{:?}", network.evaluate(&[2.0, 0.0]).unwrap());
24//! ```
25//!
26//! See [`Network`] for full documentation.
27//!
28//! [0]: https://dl.acm.org/doi/10.1145/1276958.1277162
29//! [1]: https://github.com/wbrickner/const_cge
30//! [2]: https://github.com/pengowen123/eant2
31
32pub mod activation;
33#[cfg(feature = "serde")]
34pub mod encoding;
35pub mod gene;
36pub mod network;
37mod stack;
38
39pub use self::activation::Activation;
40#[cfg(feature = "serde")]
41pub use self::encoding::WithRecurrentState;
42pub use self::network::Network;