Trait dfdx::nn::ResetParams
source · [−]pub trait ResetParams {
fn reset_params<R: Rng>(&mut self, rng: &mut R);
}
Expand description
Something that can reset it’s parameters.
Required Methods
fn reset_params<R: Rng>(&mut self, rng: &mut R)
fn reset_params<R: Rng>(&mut self, rng: &mut R)
Mutate the unit’s parameters using rand::Rng. Each implementor
of this trait decides how the parameters are initialized. In
fact, some impls may not even use the rng
.
Example:
struct MyMulLayer {
scale: Tensor1D<5, NoneTape>,
}
impl ResetParams for MyMulLayer {
fn reset_params<R: rand::Rng>(&mut self, rng: &mut R) {
for i in 0..5 {
self.scale.mut_data()[i] = rng.gen_range(0.0..1.0);
}
}
}