NetDEM v1.0
|
A class that represents a feedforward neural network for regression. More...
#include <regression_net.hpp>
Public Member Functions | |
void | ResetModel () |
Resets the neural network model. | |
void | AddLayer (MLPackUtils::LayerType layer_name,...) |
Adds a layer to the neural network model. | |
void | Train (const arma::mat &data_x, const arma::mat &data_y) |
Trains the neural network model with data. | |
arma::mat | Predict (const arma::mat &data_x) |
Predicts with the neural network model using input data. | |
arma::mat | Gradient (const arma::mat &data_x) |
Calculates the gradient of the neural network model with respect to input data. | |
void | Load (std::string const &filename, std::string const &label) |
Loads the neural network model from disk. | |
void | Save (std::string const &filename, std::string const &label) |
Saves the neural network model to disk. | |
Public Attributes | |
mlpack::FFN< mlpack::MeanSquaredError, mlpack::HeInitialization > | model |
The model object that represents the neural network. | |
double | step_size {0.01} |
The step size used for optimization during training. | |
int | batch_size {32} |
The batch size used for mini-batch gradient descent during training. | |
double | decay_rate_moment {0.9} |
The decay rate used for momentum during training. | |
double | decay_rate_norm {0.9} |
The decay rate used for weight normalization during training. | |
double | gradient_init_param {1e-8} |
Initial parameter value used for weight initialization during training. | |
int | epochs {100} |
The number of epochs used for training. | |
double | stop_tol {1e-8} |
The stopping tolerance used for determining when to stop training. | |
bool | enable_logging {true} |
Whether or not to enable logging during training. | |
A class that represents a feedforward neural network for regression.
The RegressionNet
class is a specific implementation of a feedforward neural network for regression. It provides functionality to reset the model, add layers to the model, train the model with data, predict with the model, calculate the gradient of the model with respect to the input data, and load/save the model to disk.
void netdem::RegressionNet::AddLayer | ( | MLPackUtils::LayerType | layer_name, |
... ) |
Adds a layer to the neural network model.
This function adds a layer to the neural network model.
layer_name | The type of layer to add. |
... | Additional arguments depending on the type of layer being added. |
For MLPackUtils::LayerType::Linear
, an additional parameter indicating the dimension of outputs is required.
arma::mat netdem::RegressionNet::Gradient | ( | const arma::mat & | data_x | ) |
Calculates the gradient of the neural network model with respect to input data.
This function calculates the gradient of the neural network model with respect to the input data using backpropagation.
data_x | The input data matrix. |
void netdem::RegressionNet::Load | ( | std::string const & | filename, |
std::string const & | label ) |
Loads the neural network model from disk.
This function loads the neural network model from disk.
filename | The name of the file containing the model data. |
label | The label of the model data within the file (if applicable). |
arma::mat netdem::RegressionNet::Predict | ( | const arma::mat & | data_x | ) |
Predicts with the neural network model using input data.
This function predicts with the neural network model using the provided input data.
data_x | The input data matrix. |
void netdem::RegressionNet::ResetModel | ( | ) |
Resets the neural network model.
This function resets the neural network model.
void netdem::RegressionNet::Save | ( | std::string const & | filename, |
std::string const & | label ) |
Saves the neural network model to disk.
This function saves the neural network model to disk.
filename | The name of the file to save the model data to. |
label | The label of the model data within the file (if applicable). |
void netdem::RegressionNet::Train | ( | const arma::mat & | data_x, |
const arma::mat & | data_y ) |
Trains the neural network model with data.
This function trains the neural network model with the provided input and output data using mini-batch gradient descent with momentum and weight normalization.
data_x | The input data matrix. |
data_y | The output data matrix. |
int netdem::RegressionNet::batch_size {32} |
The batch size used for mini-batch gradient descent during training.
double netdem::RegressionNet::decay_rate_moment {0.9} |
The decay rate used for momentum during training.
double netdem::RegressionNet::decay_rate_norm {0.9} |
The decay rate used for weight normalization during training.
bool netdem::RegressionNet::enable_logging {true} |
Whether or not to enable logging during training.
int netdem::RegressionNet::epochs {100} |
The number of epochs used for training.
double netdem::RegressionNet::gradient_init_param {1e-8} |
Initial parameter value used for weight initialization during training.
mlpack::FFN<mlpack::MeanSquaredError, mlpack::HeInitialization> netdem::RegressionNet::model |
The model object that represents the neural network.
double netdem::RegressionNet::step_size {0.01} |
The step size used for optimization during training.
double netdem::RegressionNet::stop_tol {1e-8} |
The stopping tolerance used for determining when to stop training.