NeuralNet 1.0
|
Public Member Functions | |
void | setup (const std::shared_ptr< Optimizer > &optimizer, LOSS loss=LOSS::QUADRATIC) |
Method that sets up the model's hyperparameter. | |
void | addLayer (std::shared_ptr< Layer > &layer) |
Method to add a layer to the network. | |
void | setLoss (LOSS loss) |
This method will set the network's loss function. | |
std::shared_ptr< Layer > | getLayer (int index) const |
This method will return the Layer residing at the specified index. | |
std::shared_ptr< Layer > | getOutputLayer () const |
This method will return the output layer (the last layer of the network) | |
size_t | getNumLayers () const |
This method will get you the number of layers currently in the Network. | |
std::string | getSlug () const |
Get the slug of the network based on it's architecture. | |
double | train (std::vector< std::vector< double > > X, std::vector< double > y, int epochs=1, const std::vector< std::shared_ptr< Callback > > callbacks={}, bool progBar=true) |
This method will Train the model with the given inputs and labels. | |
double | train (std::vector< std::vector< std::vector< double > > > X, std::vector< double > y, int epochs=1, const std::vector< std::shared_ptr< Callback > > callbacks={}, bool progBar=true) |
This method will Train the model with the given inputs and labels. | |
double | train (TrainingData< std::vector< std::vector< double > >, std::vector< double > > trainingData, int epochs=1, const std::vector< std::shared_ptr< Callback > > callbacks={}, bool progBar=true) |
This method will train the model with the given TrainingData. | |
double | train (TrainingData< std::vector< std::vector< std::vector< double > > >, std::vector< double > > trainingData, int epochs=1, const std::vector< std::shared_ptr< Callback > > callbacks={}, bool progBar=true) |
This method will train the model with the given TrainingData. | |
Eigen::MatrixXd | predict (std::vector< std::vector< double > > inputs) |
This model will try to make predictions based off the inputs passed. | |
Eigen::MatrixXd | predict (std::vector< std::vector< std::vector< double > > > inputs) |
This model will try to make predictions based off the inputs passed. | |
void | to_file (const std::string &filename) override |
Save the current model to a binary file. | |
void | from_file (const std::string &filename) override |
Load a model's params from a file. | |
Friends | |
class | cereal::access |
Additional Inherited Members | |
![]() | |
template<typename T , typename = typename std::enable_if< std::is_base_of<Model, T>::value>::type> | |
static void | save_to_file (const std::string &filename, T model) |
This method will save (by serializing) the model passed as argument to a .bin file. | |
template<typename T , typename = typename std::enable_if< std::is_base_of<Model, T>::value>::type> | |
static void | load_from_file (const std::string &filename, T &model) |
This static method loads a Model from a file and assigns it to the supposedly "empty" model passed as argument. | |
![]() | |
void | registerSignals () const |
![]() | |
int | cEpoch = 0 |
double | loss = 0 |
double | accuracy = 0 |
double | testLoss = 0 |
double | testAccuracy = 0 |
void Network::addLayer | ( | std::shared_ptr< Layer > & | layer | ) |
Method to add a layer to the network.
layer | the layer to add to the model it should be of type Layer |
|
inlineoverridevirtual |
Load a model's params from a file.
filename | the name of the from which to load the model params |
Implements NeuralNet::Model.
std::shared_ptr< Layer > Network::getLayer | ( | int | index | ) | const |
size_t Network::getNumLayers | ( | ) | const |
std::shared_ptr< Layer > Network::getOutputLayer | ( | ) | const |
This method will return the output layer (the last layer of the network)
std::string Network::getSlug | ( | ) | const |
Get the slug of the network based on it's architecture.
Eigen::MatrixXd Network::predict | ( | std::vector< std::vector< double > > | inputs | ) |
This model will try to make predictions based off the inputs passed.
inputs | The inputs that will be passed through the network |
Eigen::MatrixXd Network::predict | ( | std::vector< std::vector< std::vector< double > > > | inputs | ) |
This model will try to make predictions based off the inputs passed.
inputs | The inputs that will be passed through the network |
void Network::setLoss | ( | LOSS | loss | ) |
This method will set the network's loss function.
loss | The loss function (choose from the list of LOSS enums) |
void Network::setup | ( | const std::shared_ptr< Optimizer > & | optimizer, |
LOSS | loss = LOSS::QUADRATIC ) |
Method that sets up the model's hyperparameter.
optimizer | An Optimizer's child class |
epochs | The number of epochs |
loss | The loss function |
|
inlineoverridevirtual |
Save the current model to a binary file.
filename | the name of the file in which to save the model params |
Implements NeuralNet::Model.
double Network::train | ( | std::vector< std::vector< double > > | X, |
std::vector< double > | y, | ||
int | epochs = 1, | ||
const std::vector< std::shared_ptr< Callback > > | callbacks = {}, | ||
bool | progBar = true ) |
This method will Train the model with the given inputs and labels.
X | The inputs that will be passed to the model |
y | The labels that represent the expected outputs of the model |
epochs | |
callbacks | A vector of Callback that will be called during training stages |
progBar | Ouput a progress bar for the training process . Default: true |
double Network::train | ( | std::vector< std::vector< std::vector< double > > > | X, |
std::vector< double > | y, | ||
int | epochs = 1, | ||
const std::vector< std::shared_ptr< Callback > > | callbacks = {}, | ||
bool | progBar = true ) |
This method will Train the model with the given inputs and labels.
inputs | The inputs that will be passed to the model |
labels | The labels that represent the expected outputs of the model |
epochs | |
callbacks | A vector of Callback that will be called during training stages |
progBar | Whether to output a progress bar for the training process. Default: true |
double Network::train | ( | TrainingData< std::vector< std::vector< double > >, std::vector< double > > | trainingData, |
int | epochs = 1, | ||
const std::vector< std::shared_ptr< Callback > > | callbacks = {}, | ||
bool | progBar = true ) |
This method will train the model with the given TrainingData.
trainingData | the data passed through the TrainingData class |
epochs | |
callbacks | A vector of Callback that will be called during training stages |
progBar | Whether to output a progress bar for the training process. Default: true |
double Network::train | ( | TrainingData< std::vector< std::vector< std::vector< double > > >, std::vector< double > > | trainingData, |
int | epochs = 1, | ||
const std::vector< std::shared_ptr< Callback > > | callbacks = {}, | ||
bool | progBar = true ) |
This method will train the model with the given TrainingData.
trainingData | the data passed through the TrainingData class |
epochs | |
callbacks | A vector of Callback that will be called during training stages |
progBar | Whether to output a progress bar for the training process. Default: true |