Enum burn_core::nn::Initializer
source · 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,
},
}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
Fields
Fills tensor with values drawn from normal distribution with specified mean and std
KaimingUniform
Fields
Fills tensor with values according to the uniform version of Kaiming initialization
KaimingNormal
Fields
Fills tensor with values according to the uniform version of Kaiming initialization
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
Implementations§
source§impl Initializer
impl Initializer
sourcepub fn init<B: Backend, const D: usize, S: Into<Shape<D>>>(
&self,
shape: S
) -> Tensor<B, D>
pub fn init<B: Backend, const D: usize, S: Into<Shape<D>>>( &self, shape: S ) -> Tensor<B, D>
Inits a tensor 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<D>>>(
&self,
shape: S,
fan_in: Option<usize>,
fan_out: Option<usize>
) -> Tensor<B, D>
pub fn init_with<B: Backend, const D: usize, S: Into<Shape<D>>>( &self, shape: S, fan_in: Option<usize>, fan_out: Option<usize> ) -> Tensor<B, D>
Inits a tensor of given shape with values depending on initializer kind, with the possibility of specifying fan in and fan out
Params
- shape: Shape of the initiated tensor.
- fan_in:
Option<usize>, the fan in to use in initialization formula, if needed - fan_out:
Option<usize>, the fan out to use in initialization formula, if needed
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<()>
source§fn load<P: AsRef<Path>>(file: P) -> Result<Self, ConfigError>
fn load<P: AsRef<Path>>(file: P) -> Result<Self, ConfigError>
source§fn load_binary(data: &[u8]) -> Result<Self, ConfigError>
fn load_binary(data: &[u8]) -> Result<Self, ConfigError>
source§impl Debug for Initializer
impl Debug for Initializer
source§impl<'de> Deserialize<'de> for Initializer
impl<'de> Deserialize<'de> for Initializer
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where D: Deserializer<'de>,
source§impl Display for Initializer
impl Display for Initializer
source§impl PartialEq for Initializer
impl PartialEq for Initializer
source§fn eq(&self, other: &Initializer) -> bool
fn eq(&self, other: &Initializer) -> bool
self and other values to be equal, and is used
by ==.