concision_core/params/impls/
impl_init.rs1use crate::params::ParamsBase;
2
3use ndarray::{Data, DataOwned, Dimension, ScalarOperand, ShapeBuilder};
4use num_traits::{Float, FromPrimitive};
5
6impl<A, S, D> ParamsBase<S, D>
7where
8 A: Float + FromPrimitive + ScalarOperand,
9 D: Dimension,
10 S: Data<Elem = A>,
11{
12 #[cfg(feature = "rand")]
13 pub fn init_rand<G, Dst, Sh>(shape: Sh, distr: G) -> Self
14 where
15 D: ndarray::RemoveAxis,
16 S: DataOwned,
17 Sh: ShapeBuilder<Dim = D>,
18 Dst: Clone + rand_distr::Distribution<A>,
19 G: Fn(&Sh) -> Dst,
20 {
21 use crate::init::Initialize;
22 let dist = distr(&shape);
23 Self::rand(shape, dist)
24 }
25}