|
MLask 1.0.0
A custom c++ deep learning library
|
Class representing a neural network model. More...
#include <Model.hpp>
Public Member Functions | |
| Model (std::size_t in, std::size_t out, std::size_t size=0, std::size_t epochs=0, bool log=false) | |
| Constructs a model. | |
| void | addLayer (std::unique_ptr< Layer > layer) |
| Adds a layer to the model(Layer is an abstract class, see Layer.hpp for more details) | |
| template<TLayer layer, typename... Args> | |
| void | addLayer (Args &&... args) |
| Adds a layer to the model(Layer is an abstract class, see Layer.hpp for more details) | |
| template<std::size_t in, std::size_t out> | |
| void | addFullyConnectedLayer () |
| creates and adds fullyConnectedLayer with given in and out neurons | |
| void | addLambdaActivationFunction (actfunc func, actfunc derv) |
| creates and adds ActivationFunction layer with give function form and derived form | |
| template<ErrorFunction err> | |
| void | backprop (vectorIn input, vectorOut expected) |
| performs backpropagation algorithm | |
| void | fit (float_t learning_rate) |
| Fits the entire model(every layer added) | |
| vectorOut | forward (vectorIn input) const |
| calculates the output for given input | |
| template<ErrorFunction err> | |
| float_t | error (vectorIn input, vectorOut expected) const |
| calculates an error of a model | |
| template<ErrorFunction err> | |
| float_t | whole_error (Eigen::Matrix< float_t, Eigen::Dynamic, Eigen::Dynamic > input, Eigen::Matrix< float_t, Eigen::Dynamic, Eigen::Dynamic > expected) const |
| calculates an error of a model based on many inputs | |
| const Layer * | getLayer (std::size_t index) const |
| gets the layer at a given index | |
| const Layer * | operator[] (std::size_t index) const |
| std::string | str () const |
| Returns a string representation of the model. | |
| void | exportToONNX (std::filesystem::path path, std::string name="MLask Model") const |
| exports the model to a file in ONNX format | |
Class representing a neural network model.
| mlask::Model::Model | ( | std::size_t | in, |
| std::size_t | out, | ||
| std::size_t | size = 0, |
||
| std::size_t | epochs = 0, |
||
| bool | log = false |
||
| ) |
Constructs a model.
| in | number of input neurons |
| out | number of output neurons |
| size | number of layers in the model (optional for optimization) |
| epochs | number of epochs to train the model (optional for logging) |
| log | whether to log the training process (optional for logging) |
| void mlask::Model::addFullyConnectedLayer | ( | ) |
creates and adds fullyConnectedLayer with given in and out neurons
| in | number of input neurons |
| out | number of output neurons |
| ArchitectureError | if the input size of the layer does not match the output size of the previous layer |
creates and adds ActivationFunction layer with give function form and derived form
| func | The activation function |
| derv | The derivative of the activation function |
Adds a layer to the model(Layer is an abstract class, see Layer.hpp for more details)
| layer | The layer to add |
| ArchitectureError | if the input size of the layer does not match the output size of the previous layer |
performs backpropagation algorithm
| input | the input vector for the model |
| expected | the expected output vector for the given input |
| err | ErrorFunction used to calculate error, notice that this should be derived version |
| float_t mlask::Model::error | ( | vectorIn | input, |
| vectorOut | expected | ||
| ) | const |
calculates an error of a model
| input | The input vector for the model |
| expected | The expected vector of values |
| err | the error function (see ErrorFunction.hpp or include/error_functions) |
| void mlask::Model::exportToONNX | ( | std::filesystem::path | path, |
| std::string | name = "MLask Model" |
||
| ) | const |
exports the model to a file in ONNX format
| path | The path to the file where the model will be saved |
| name | The name of the model to be used in the ONNX file (optional, default is "MLask Model") |
| throws | ExportError if the export failed |
Fits the entire model(every layer added)
| learning_rate | The learning rate for the model |
calculates the output for given input
| input | The input vector for the model |
gets the layer at a given index
| index | The index of the layer to get |
|
inline |
| std::string mlask::Model::str | ( | ) | const |
Returns a string representation of the model.
| float_t mlask::Model::whole_error | ( | Eigen::Matrix< float_t, Eigen::Dynamic, Eigen::Dynamic > | input, |
| Eigen::Matrix< float_t, Eigen::Dynamic, Eigen::Dynamic > | expected | ||
| ) | const |
calculates an error of a model based on many inputs
| input | The input matrix for the model |
| expected | The expected matrix of values |
| err | the error function (see ErrorFunction.hpp or include/error_functions) |