pub struct ModelParamsBase<S, D = Ix2>{
pub input: ParamsBase<S, D>,
pub hidden: Vec<ParamsBase<S, D>>,
pub output: ParamsBase<S, D>,
}Expand description
This object is an abstraction over the parameters of a deep neural network model. This is done to isolate the necessary parameters from the specific logic within a model allowing us to easily create additional stores for tracking velocities, gradients, and other metrics we may need.
Additionally, this provides us with a way to introduce common creation routines for initializing neural networks.
Fields§
§input: ParamsBase<S, D>the input layer of the model
a sequential stack of params for the model’s hidden layers
output: ParamsBase<S, D>the output layer of the model
Implementations§
Source§impl<A, S, D> ModelParamsBase<S, D>
impl<A, S, D> ModelParamsBase<S, D>
pub fn new( input: ParamsBase<S, D>, hidden: Vec<ParamsBase<S, D>>, output: ParamsBase<S, D>, ) -> Self
Sourcepub fn is_shallow(&self) -> bool
pub fn is_shallow(&self) -> bool
returns true if the stack is shallow
Sourcepub const fn input(&self) -> &ParamsBase<S, D>
pub const fn input(&self) -> &ParamsBase<S, D>
returns an immutable reference to the input layer of the model
Sourcepub fn input_mut(&mut self) -> &mut ParamsBase<S, D>
pub fn input_mut(&mut self) -> &mut ParamsBase<S, D>
returns a mutable reference to the input layer of the model
returns an immutable reference to the hidden layers of the model
returns an immutable reference to the hidden layers of the model as a slice
returns a mutable reference to the hidden layers of the model
Sourcepub const fn output(&self) -> &ParamsBase<S, D>
pub const fn output(&self) -> &ParamsBase<S, D>
returns an immutable reference to the output layer of the model
Sourcepub fn output_mut(&mut self) -> &mut ParamsBase<S, D>
pub fn output_mut(&mut self) -> &mut ParamsBase<S, D>
returns a mutable reference to the output layer of the model
Sourcepub fn set_input(&mut self, input: ParamsBase<S, D>)
pub fn set_input(&mut self, input: ParamsBase<S, D>)
set the input layer of the model
set the hidden layers of the model
Sourcepub fn set_output(&mut self, output: ParamsBase<S, D>)
pub fn set_output(&mut self, output: ParamsBase<S, D>)
set the output layer of the model
Sourcepub fn with_input(self, input: ParamsBase<S, D>) -> Self
pub fn with_input(self, input: ParamsBase<S, D>) -> Self
consumes the current instance and returns another with the specified input layer
consumes the current instance and returns another with the specified hidden layers
Sourcepub fn with_output(self, output: ParamsBase<S, D>) -> Self
pub fn with_output(self, output: ParamsBase<S, D>) -> Self
consumes the current instance and returns another with the specified output layer
returns the dimension of the hidden layers
Sourcepub fn dim_output(&self) -> <D as Dimension>::Pattern
pub fn dim_output(&self) -> <D as Dimension>::Pattern
returns the dimension of the output layer
Source§impl<A, S> ModelParamsBase<S>where
S: RawData<Elem = A>,
impl<A, S> ModelParamsBase<S>where
S: RawData<Elem = A>,
Sourcepub fn default(features: ModelFeatures) -> Self
pub fn default(features: ModelFeatures) -> Self
create a new instance of the model; all parameters are initialized to their defaults (i.e., zero)
Sourcepub fn ones(features: ModelFeatures) -> Self
pub fn ones(features: ModelFeatures) -> Self
create a new instance of the model; all parameters are initialized to zero
Sourcepub fn zeros(features: ModelFeatures) -> Self
pub fn zeros(features: ModelFeatures) -> Self
create a new instance of the model; all parameters are initialized to zero
pub fn init_rand<G, Ds>(features: ModelFeatures, distr: G) -> Self
Sourcepub fn glorot_normal(features: ModelFeatures) -> Self
pub fn glorot_normal(features: ModelFeatures) -> Self
initialize the model parameters using a glorot normal distribution
Sourcepub fn glorot_uniform(features: ModelFeatures) -> Selfwhere
S: DataOwned,
A: Clone + Float + FromPrimitive + SampleUniform,
<S::Elem as SampleUniform>::Sampler: Clone,
Uniform<S::Elem>: Distribution<S::Elem>,
pub fn glorot_uniform(features: ModelFeatures) -> Selfwhere
S: DataOwned,
A: Clone + Float + FromPrimitive + SampleUniform,
<S::Elem as SampleUniform>::Sampler: Clone,
Uniform<S::Elem>: Distribution<S::Elem>,
initialize the model parameters using a glorot uniform distribution