Struct intricate::layers::initializers::ConstantInitializer
source · pub struct ConstantInitializer {
pub constant: f32,
}Expand description
A Initializer that pretty much just initializes all values of a parameter with a constat value provided by the new method
Fields§
§constant: f32The constant that all the parameters will be
Implementations§
source§impl ConstantInitializer
impl ConstantInitializer
sourcepub fn new(constant: f32) -> Self
pub fn new(constant: f32) -> Self
Creates a new Constant initializer
Examples found in repository?
src/layers/conv2d.rs (line 147)
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
pub fn new_raw(inputs_size: (usize, usize), filter_size: (usize, usize)) -> Self {
let mut initializers = HashMap::with_capacity(2);
initializers.insert(
"weights".to_string(),
GlorotUniformInitializer::new().into(),
);
initializers.insert("biases".to_string(), ConstantInitializer::new(0.0).into());
Conv2D {
inputs_size,
filter_size,
weights: Vec::default(),
biases: Vec::default(),
initializers,
weights_buff: None,
biases_buff: None,
last_inputs_buffer: None,
last_outputs_buffer: None,
opencl_state: None,
}
}More examples
src/layers/dense.rs (line 135)
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
pub fn new_raw(inputs_amount: usize, outputs_amount: usize) -> Dense<'a> {
let mut initializers = HashMap::with_capacity(2);
initializers.insert("weights".to_string(), GlorotUniformInitializer::new().into());
initializers.insert("biases".to_string(), ConstantInitializer::new(0.0).into());
Dense {
inputs_amount,
outputs_amount,
initializers,
weights: Vec::default(),
biases: Vec::default(),
weights_buffer: None,
biases_buffer: None,
last_inputs_buffer: None,
last_outputs_buffer: None,
opencl_state: None,
}
.into() // because ModelLayer implements From<Dense>
}Trait Implementations§
source§impl Clone for ConstantInitializer
impl Clone for ConstantInitializer
source§fn clone(&self) -> ConstantInitializer
fn clone(&self) -> ConstantInitializer
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for ConstantInitializer
impl Debug for ConstantInitializer
source§impl Deserialize for ConstantInitializer
impl Deserialize for ConstantInitializer
source§fn deserialize(
deserializer: &mut Deserializer<'_>
) -> Result<Self, SavefileError>
fn deserialize(
deserializer: &mut Deserializer<'_>
) -> Result<Self, SavefileError>
Deserialize and return an instance of Self from the given deserializer.
source§impl From<ConstantInitializer> for Initializer
impl From<ConstantInitializer> for Initializer
source§fn from(v: ConstantInitializer) -> Self
fn from(v: ConstantInitializer) -> Self
Converts to this type from the input type.
source§impl InitializerTrait for ConstantInitializer
impl InitializerTrait for ConstantInitializer
source§fn initialize_0d<'a>(&self, _: &dyn Layer<'a>) -> f32
fn initialize_0d<'a>(&self, _: &dyn Layer<'a>) -> f32
Generates just one number based on the Initializer’s implementation
source§fn initialize_1d<'a>(&self, count: usize, layer: &dyn Layer<'a>) -> Vec<f32> ⓘ
fn initialize_1d<'a>(&self, count: usize, layer: &dyn Layer<'a>) -> Vec<f32> ⓘ
Generates a Vec of numbers initialized based on the Initializer’s implementation
source§impl Introspect for ConstantInitializer
impl Introspect for ConstantInitializer
source§fn introspect_value(&self) -> String
fn introspect_value(&self) -> String
Returns the value of the object, excluding children, as a string.
Exactly what the value returned here is depends on the type.
For some types, like a plain array, there isn’t much of a value,
the entire information of object resides in the children.
For other cases, like a department in an organisation, it might
make sense to have the value be the name, and have all the other properties
as children.
source§fn introspect_child(
&self,
index: usize
) -> Option<Box<dyn IntrospectItem<'_> + '_>>
fn introspect_child(
&self,
index: usize
) -> Option<Box<dyn IntrospectItem<'_> + '_>>
Returns an the name and &dyn Introspect for the child with the given index,
or if no child with that index exists, None.
All the children should be indexed consecutively starting at 0 with no gaps,
all though there isn’t really anything stopping the user of the trait to have
any arbitrary index strategy, consecutive numbering 0, 1, 2, … etc is strongly
encouraged.
source§fn introspect_len(&self) -> usize
fn introspect_len(&self) -> usize
Returns the total number of children.
The default implementation calculates this by simply calling introspect_child with
higher and higher indexes until it returns None.
It gives up if the count reaches 10000. If your type can be bigger
and you want to be able to introspect it, override this method.
source§impl Serialize for ConstantInitializer
impl Serialize for ConstantInitializer
source§fn serialize(&self, serializer: &mut Serializer<'_>) -> Result<(), SavefileError>
fn serialize(&self, serializer: &mut Serializer<'_>) -> Result<(), SavefileError>
Serialize self into the given serializer.