concision_core/init/
initializer.rs1use super::Initialize;
6use core::marker::PhantomData;
7use nd::prelude::*;
8use nd::DataOwned;
9use rand_distr::{Distribution, StandardNormal};
10
11pub struct InitializerBase<A = f64, D = Ix2, Dst = StandardNormal>
12where
13 D: Dimension,
14 Dst: Clone + Distribution<A>,
15{
16 pub(crate) dim: D,
17 pub(crate) distr: Dst,
18 pub(crate) _dtype: PhantomData<A>,
19}
20
21impl<A, D, Dst> InitializerBase<A, D, Dst>
22where
23 D: Dimension,
24 Dst: Clone + Distribution<A>,
25{
26 pub fn new(dim: D, distr: Dst) -> Self {
27 Self {
28 dim,
29 distr,
30 _dtype: PhantomData::<A>,
31 }
32 }
33
34 pub fn init<S>(self) -> ArrayBase<S, D>
35 where
36 S: DataOwned<Elem = A>,
37 {
38 ArrayBase::rand(self.dim, self.distr)
39 }
40}