concision_neural/lib.rs
1/*
2 Appellation: concision-neural <library>
3 Contrib: @FL03
4*/
5//! Various components, implementations, and traits for creating neural networks. The crate
6//! builds off of the [`concision_core`] crate, making extensive use of the [`ParamsBase`](cnc::ParamsBase)
7//! type to define the parameters of layers within a network.
8//!
9//! ## Overview
10//!
11//! Neural networks are a fundamental part of machine learning, and this crate provides a
12//! comprehensive set of tools to build, configure, and train neural network models. Listed
13//! below are several key components of the crate:
14//!
15//! - [`Model`]: A trait for defining a neural network model.
16//! - [`StandardModelConfig`]: A standard configuration for the models
17//! - [`ModelFeatures`]: A default implementation of the [`ModelLayout`] trait that
18//! sufficiently defines both shallow and deep neural networks.
19//!
20//! ### _Model Parameters_
21//!
22//! Additionally, the crate defines a sequential
23//!
24//! **Note**: You should stick with the type aliases for the [`ModelParamsBase`] type, as they
25//! drastically simplify the type-face of the model parameters. Attempting to generalize over
26//! the hidden layers of the model might lead to excessive complexity. That being said, there
27//! are provided methods and routines to convert from a shallow to deep model, and vice versa.
28//!
29//! - [`DeepModelParams`]: An owned representation of the [`ModelParamsBase`] for deep
30//! neural networks.
31//! - [`ShallowModelParams`]: An owned representation of the [`ModelParamsBase`] for shallow
32//! neural networks.
33//!
34//! ### Traits
35//!
36//! This crate extends the [`Forward`](cnc::Forward) and [`Backward`](cnc::Backward) traits
37//! from the [`core`](cnc) crate to provide additional functionality for neural networks.
38//!
39//! - [`Predict`]: A more robust implementation of the [`Forward`] trait
40//! - [`Train`]: A trait for training a neural network model.
41//!
42#![cfg_attr(not(feature = "std"), no_std)]
43#![allow(
44 clippy::missing_saftey_doc,
45 clippy::module_inception,
46 clippy::needless_doctest_main,
47 clippy::upper_case_acronyms
48)]
49// ensure that either `std` or `alloc` feature is enabled
50#[cfg(not(any(feature = "std", feature = "alloc")))]
51compile_error! {
52 "At least one of the 'std' or 'alloc' features must be enabled."
53}
54
55extern crate concision_core as cnc;
56
57#[cfg(feature = "alloc")]
58extern crate alloc;
59
60#[doc(inline)]
61pub use self::{
62 config::prelude::*,
63 error::*,
64 layers::{Layer, LayerBase},
65 layout::prelude::*,
66 params::prelude::*,
67 train::prelude::*,
68 traits::*,
69 types::*,
70};
71
72#[macro_use]
73pub(crate) mod macros {
74 #[macro_use]
75 pub mod seal;
76}
77
78pub mod config;
79pub mod error;
80pub mod layers;
81pub mod layout;
82pub mod params;
83pub mod train;
84
85pub(crate) mod traits {
86 #[doc(inline)]
87 pub use self::prelude::*;
88
89 mod hidden;
90 mod models;
91 mod predict;
92
93 mod prelude {
94 #[doc(inline)]
95 pub use super::hidden::*;
96 #[doc(inline)]
97 pub use super::models::*;
98 #[doc(inline)]
99 pub use super::predict::*;
100 }
101}
102
103pub(crate) mod types {
104 #[doc(inline)]
105 pub use self::prelude::*;
106
107 mod dropout;
108 mod key_value;
109
110 mod prelude {
111 #[doc(inline)]
112 pub use super::dropout::*;
113 #[doc(inline)]
114 pub use super::key_value::*;
115 }
116}
117
118#[doc(hidden)]
119pub mod prelude {
120 #[doc(no_inline)]
121 pub use super::config::prelude::*;
122 #[doc(hidden)]
123 pub use crate::layers::prelude::*;
124 #[doc(no_inline)]
125 pub use crate::layout::prelude::*;
126 #[doc(no_inline)]
127 pub use crate::params::prelude::*;
128 #[doc(no_inline)]
129 pub use crate::train::prelude::*;
130 #[doc(no_inline)]
131 pub use crate::traits::*;
132 #[doc(no_inline)]
133 pub use crate::types::*;
134}