use super::ModelLayout;
use crate::models::{Deep, NetworkDepth, RawModelLayout, Shallow};
impl<F, D> ModelLayout<F, D>
where
F: RawModelLayout,
D: NetworkDepth,
{
pub const fn new(features: F) -> Self {
Self {
features,
_marker: core::marker::PhantomData::<D>,
}
}
pub const fn features(&self) -> &F {
&self.features
}
pub const fn features_mut(&mut self) -> &mut F {
&mut self.features
}
pub fn input(&self) -> usize {
self.features().input()
}
pub fn output(&self) -> usize {
self.features().output()
}
pub fn hidden(&self) -> usize {
self.features().hidden()
}
pub fn layers(&self) -> usize {
self.features().depth()
}
}
impl<F, D> core::ops::Deref for ModelLayout<F, D>
where
F: RawModelLayout,
D: NetworkDepth,
{
type Target = F;
fn deref(&self) -> &Self::Target {
&self.features
}
}
impl<F, D> core::ops::DerefMut for ModelLayout<F, D>
where
F: RawModelLayout,
D: NetworkDepth,
{
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.features
}
}
impl<F> ModelLayout<F, Deep>
where
F: RawModelLayout,
{
pub const fn deep(features: F) -> Self {
Self::new(features)
}
}
impl<F> ModelLayout<F, Shallow>
where
F: RawModelLayout,
{
pub const fn shallow(features: F) -> Self {
Self::new(features)
}
}