concision_params/impls/
impl_params_repr.rs

1/*
2    appellation: impl_params_repr <module>
3    authors: @FL03
4*/
5use crate::params_base::ParamsBase;
6
7use ndarray::{ArrayBase, DataOwned, Dimension, Ix1, Ix2, RawData};
8
9impl<A, S, D> ParamsBase<S, D, A>
10where
11    D: Dimension,
12    S: RawData<Elem = A>,
13{
14}
15
16impl<A, S> ParamsBase<S, Ix1>
17where
18    S: RawData<Elem = A>,
19{
20    /// returns a new instance of the [`ParamsBase`] initialized using a _scalar_ bias along
21    /// with the given, one-dimensional weight tensor.
22    pub fn from_scalar_bias(bias: A, weights: ArrayBase<S, Ix1>) -> Self
23    where
24        A: Clone,
25        S: DataOwned,
26    {
27        Self {
28            bias: ArrayBase::from_elem((), bias),
29            weights,
30        }
31    }
32    /// returns the number of rows in the weights tensor
33    pub fn nrows(&self) -> usize {
34        self.weights().len()
35    }
36}
37
38impl<A, S> ParamsBase<S, Ix2>
39where
40    S: RawData<Elem = A>,
41{
42    /// returns the number of columns in the weights tensor
43    pub fn ncols(&self) -> usize {
44        self.weights().ncols()
45    }
46    /// returns the number of rows in the weights tensor
47    pub fn nrows(&self) -> usize {
48        self.weights().nrows()
49    }
50}