pub enum Initializer {
Constant {
value: f64,
},
Ones,
Zeros,
Uniform {
min: f64,
max: f64,
},
Normal {
mean: f64,
std: f64,
},
KaimingUniform {
gain: f64,
fan_out_only: bool,
},
KaimingNormal {
gain: f64,
fan_out_only: bool,
},
XavierUniform {
gain: f64,
},
XavierNormal {
gain: f64,
},
Orthogonal {
gain: f64,
},
}Expand description
Enum specifying with what values a tensor should be initialized
Variants§
Constant
Fills tensor with specified value everywhere
Ones
Fills tensor with 1s everywhere
Zeros
Fills tensor with 0s everywhere
Uniform
Fills tensor with values drawn uniformly between specified values
Normal
Fills tensor with values drawn from normal distribution with specified mean and std
Fields
KaimingUniform
Fills tensor with values according to the uniform version of Kaiming initialization
Fields
KaimingNormal
Fills tensor with values according to the uniform version of Kaiming initialization
Fields
XavierUniform
Fills tensor with values according to the uniform version of Xavier Glorot initialization described in Understanding the difficulty of training deep feedforward neural networks
XavierNormal
Fills tensor with values according to the normal version of Xavier Glorot initialization described in Understanding the difficulty of training deep feedforward neural networks
Orthogonal
Fills tensor with values according to the (semi) orthogonal initialization described in [Exact solutions to the nonlinear dynamics of learning in deep linear neural networks`
Implementations§
Source§impl Initializer
impl Initializer
Sourcepub fn init<B: Backend, const D: usize, S: Into<Shape>>(
&self,
shape: S,
device: &B::Device,
) -> Param<Tensor<B, D>>
pub fn init<B: Backend, const D: usize, S: Into<Shape>>( &self, shape: S, device: &B::Device, ) -> Param<Tensor<B, D>>
Inits a tensor parameter of given shape with values depending on initializer kind.
§Params
- shape: Shape of the initiated tensor.
Sourcepub fn init_with<B: Backend, const D: usize, S: Into<Shape>>(
&self,
shape: S,
fan_in: Option<usize>,
fan_out: Option<usize>,
device: &B::Device,
) -> Param<Tensor<B, D>>
pub fn init_with<B: Backend, const D: usize, S: Into<Shape>>( &self, shape: S, fan_in: Option<usize>, fan_out: Option<usize>, device: &B::Device, ) -> Param<Tensor<B, D>>
Inits a tensor parameter of given shape with values depending on initializer kind.
§Params
- shape: Shape of the initiated tensor.
Trait Implementations§
Source§impl Clone for Initializer
impl Clone for Initializer
Source§impl Config for Initializer
impl Config for Initializer
Source§fn save<P: AsRef<Path>>(&self, file: P) -> Result<()>
fn save<P: AsRef<Path>>(&self, file: P) -> Result<()>
std only.Source§fn load<P: AsRef<Path>>(file: P) -> Result<Self, ConfigError>
fn load<P: AsRef<Path>>(file: P) -> Result<Self, ConfigError>
std only.