pub struct Sequential { /* private fields */ }
Expand description
Implementation of the neural network / sequential models of layers
Implementations§
Source§impl Sequential
impl Sequential
Sourcepub fn new(num_inputs: usize) -> Sequential
pub fn new(num_inputs: usize) -> Sequential
Create a new instance of a sequential model num_inputs = the number of inputs to the model
Sourcepub fn get_num_inputs(&self) -> usize
pub fn get_num_inputs(&self) -> usize
Returns the requested input dimension
Sourcepub fn get_layers(&self) -> &Vec<Layer>
pub fn get_layers(&self) -> &Vec<Layer>
Get the layers (as ref)
Sourcepub fn get_layers_mut(&mut self) -> &mut Vec<Layer>
pub fn get_layers_mut(&mut self) -> &mut Vec<Layer>
Get the layers (as mut)
Sourcepub fn get_params(&self) -> Vec<Float> ⓘ
pub fn get_params(&self) -> Vec<Float> ⓘ
Return the flat parameters of the layers (including LReLU factors). Used for evolution-strategies
Sourcepub fn set_params(&mut self, params: &[Float]) -> &mut Self
pub fn set_params(&mut self, params: &[Float]) -> &mut Self
Set the layers’ parameters (including LReLU factors) by a flat input. Used for evolution-strategies. Panics if params’ size does not fit the layers
Sourcepub fn add_layer(&mut self, layer: Layer) -> &mut Self
pub fn add_layer(&mut self, layer: Layer) -> &mut Self
Add a layer to the sequential model. Be sure to have appropriate
parameters inside the layer, they are not checked! You can use specific
add_layer_
Sourcepub fn add_layer_lrelu(&mut self, factor: Float) -> &mut Self
pub fn add_layer_lrelu(&mut self, factor: Float) -> &mut Self
Add a LReLU layer: factor = factor to apply to x < 0
Sourcepub fn add_layer_prelu(&mut self, factor: Float) -> &mut Self
pub fn add_layer_prelu(&mut self, factor: Float) -> &mut Self
Add a PReLU layer: factor = factor to apply to x < 0
Sourcepub fn add_layer_pelu(&mut self, a: Float, b: Float) -> &mut Self
pub fn add_layer_pelu(&mut self, a: Float, b: Float) -> &mut Self
Add a PELU layer: a and b are the specific factors
Sourcepub fn add_layer_dropout(&mut self, d: Float) -> &mut Self
pub fn add_layer_dropout(&mut self, d: Float) -> &mut Self
Add a Dropout layer: d = fraction of nodes to drop
Sourcepub fn add_layer_dense(
&mut self,
neurons: usize,
init: Initializer,
) -> &mut Self
pub fn add_layer_dense( &mut self, neurons: usize, init: Initializer, ) -> &mut Self
Add a Dense layer: neurons = number of neurons/units in the layer init = initializer to use (use He for ReLU, Glorot for Tanh)
Sourcepub fn predict(&self, inputs: &[Vec<Float>]) -> Vec<Vec<Float>>
pub fn predict(&self, inputs: &[Vec<Float>]) -> Vec<Vec<Float>>
Predict values (forward pass) for a vector of input data (Vec):
Sourcepub fn from_json(encoded: &str) -> Sequential
pub fn from_json(encoded: &str) -> Sequential
Builds a new model from a JSON string.
Sourcepub fn from_reader<R: Read>(encoded: R) -> Sequential
pub fn from_reader<R: Read>(encoded: R) -> Sequential
Builds a new model from a JSON reader (e.g. file).
Sourcepub fn load(file: &str) -> Result<Sequential, Error>
pub fn load(file: &str) -> Result<Sequential, Error>
Creates a model from a previously saved file
Sourcepub fn calc_mse(&self, target: &[(Vec<Float>, Vec<Float>)]) -> Float
pub fn calc_mse(&self, target: &[(Vec<Float>, Vec<Float>)]) -> Float
Calculate the error to a target set (Vec<(x, y)>): Mean squared error (for regression) Potentially ignores different vector lenghts!
Sourcepub fn calc_rmse(&self, target: &[(Vec<Float>, Vec<Float>)]) -> Float
pub fn calc_rmse(&self, target: &[(Vec<Float>, Vec<Float>)]) -> Float
Calculate the error to a target set (Vec<(x, y)>): Root mean squared error (for regression) Potentially ignores different vector lenghts!
Sourcepub fn calc_mae(&self, target: &[(Vec<Float>, Vec<Float>)]) -> Float
pub fn calc_mae(&self, target: &[(Vec<Float>, Vec<Float>)]) -> Float
Calculate the error to a target set (Vec<(x, y)>): Mean absolute error (for regression) Potentially ignores different vector lenghts!
Sourcepub fn calc_mape(&self, target: &[(Vec<Float>, Vec<Float>)]) -> Float
pub fn calc_mape(&self, target: &[(Vec<Float>, Vec<Float>)]) -> Float
Calculate the error to a target set (Vec<(x, y)>): Mean absolute percentage error (better don’t use if target has 0 values) (for regression) Potentially ignores different vector lenghts!
Sourcepub fn calc_logcosh(&self, target: &[(Vec<Float>, Vec<Float>)]) -> Float
pub fn calc_logcosh(&self, target: &[(Vec<Float>, Vec<Float>)]) -> Float
Calculate the error to a target set (Vec<(x, y)>): logcosh (for regression) Potentially ignores different vector lenghts!
Sourcepub fn calc_binary_crossentropy(
&self,
target: &[(Vec<Float>, Vec<Float>)],
) -> Float
pub fn calc_binary_crossentropy( &self, target: &[(Vec<Float>, Vec<Float>)], ) -> Float
Calculate the error to a target set (Vec<(x, y)>): binary cross-entropy (be sure to use 0, 1 classifiers+labels) (for classification) Potentially ignores different vector lenghts!
Trait Implementations§
Source§impl Clone for Sequential
impl Clone for Sequential
Source§fn clone(&self) -> Sequential
fn clone(&self) -> Sequential
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more