concision_core/
lib.rs

1//! This crate provides the core implementations for the `cnc` framework, defining various
2//! traits, types, and utilities essential for building neural networks.
3//!
4//! - [`ParamsBase`]: A structure for defining the parameters within a neural network.
5//! - [`Backward`]: This trait establishes a common interface for backward propagation.
6//! - [`Forward`]: This trait denotes a single forward pass through a layer of a neural network
7//!
8//! ## Features
9//!
10//! The crate is heavily feature-gate, enabling users to customize their experience based on
11//! their needs.
12//!
13//! - `utils`: Provides various utilities for developing machine learning models.
14//!
15//! ### Dependency-specific Features
16//!
17//! Additionally, the crate provides various dependency-specific features that can be enabled:
18//!
19//! - `anyhow`: Enables the use of the `anyhow` crate for error handling.
20//! - `approx`: Enables approximate equality checks for floating-point numbers.
21//! - `complex`: Enables complex number support.
22//! - `json`: Enables JSON serialization and deserialization capabilities.
23//! - `rand`: Enables random number generation
24//! - `serde`: Enables serialization and deserialization capabilities.
25//! - `tracing`: Enables tracing capabilities for debugging and logging.
26//!
27#![allow(
28    clippy::missing_safety_doc,
29    clippy::module_inception,
30    clippy::needless_doctest_main,
31    clippy::should_implement_trait,
32    clippy::upper_case_acronyms,
33    rustdoc::redundant_explicit_links
34)]
35#![cfg_attr(not(feature = "std"), no_std)]
36#![cfg_attr(all(feature = "nightly", feature = "alloc"), feature(allocator_api))]
37#![cfg_attr(all(feature = "nightly", feature = "autodiff"), feature(autodiff))]
38// compile-time checks
39#[cfg(not(any(feature = "std", feature = "alloc")))]
40compiler_error! { "Either the \"std\" feature or the \"alloc\" feature must be enabled." }
41// external crates
42#[cfg(feature = "alloc")]
43extern crate alloc;
44// re-definitions
45#[doc(inline)]
46#[cfg(feature = "rand")]
47pub use concision_init as init;
48#[doc(inline)]
49pub use concision_params as params;
50#[macro_use]
51pub(crate) mod macros {
52    #[macro_use]
53    pub mod config;
54    #[macro_use]
55    pub mod gsw;
56    #[macro_use]
57    pub mod seal;
58    #[macro_use]
59    pub mod units;
60}
61
62pub mod activate;
63pub mod config;
64pub mod error;
65pub mod models;
66pub mod nn;
67pub mod utils;
68
69#[doc(hidden)]
70pub mod ex {
71    pub mod sample;
72}
73
74mod types {
75    #[doc(inline)]
76    pub use self::parameters::*;
77
78    mod parameters;
79}
80// re-exports
81#[doc(inline)]
82pub use self::{
83    activate::{Activate, Activator, ActivatorGradient},
84    config::StandardModelConfig,
85    error::*,
86    models::prelude::*,
87    nn::prelude::*,
88    types::*,
89    utils::*,
90};
91#[doc(inline)]
92#[cfg(feature = "rand")]
93pub use concision_init::prelude::*;
94#[doc(inline)]
95pub use concision_params::prelude::*;
96#[doc(inline)]
97pub use concision_traits::prelude::*;
98
99// prelude
100#[doc(hidden)]
101pub mod prelude {
102    #[cfg(feature = "rand")]
103    pub use concision_init::prelude::*;
104    pub use concision_params::prelude::*;
105    pub use concision_traits::prelude::*;
106
107    pub use crate::config::prelude::*;
108    pub use crate::models::prelude::*;
109    pub use crate::nn::prelude::*;
110    pub use crate::types::*;
111    pub use crate::utils::*;
112}