2023-01-24 18:57:18 +01:00
|
|
|
|
|
|
|
#ifndef MLPP_MANN_H
|
|
|
|
#define MLPP_MANN_H
|
|
|
|
|
2023-01-23 21:13:26 +01:00
|
|
|
//
|
|
|
|
// MANN.hpp
|
|
|
|
//
|
|
|
|
// Created by Marc Melikyan on 11/4/20.
|
|
|
|
//
|
|
|
|
|
2023-01-24 18:12:23 +01:00
|
|
|
#include "../hidden_layer/hidden_layer.h"
|
|
|
|
#include "../multi_output_layer/multi_output_layer.h"
|
2023-01-23 21:13:26 +01:00
|
|
|
|
|
|
|
#include <string>
|
2023-01-24 19:00:54 +01:00
|
|
|
#include <vector>
|
2023-01-23 21:13:26 +01:00
|
|
|
|
2023-01-24 19:20:18 +01:00
|
|
|
|
2023-01-24 19:00:54 +01:00
|
|
|
|
2023-01-25 00:54:50 +01:00
|
|
|
class MLPPMANN {
|
2023-01-24 19:00:54 +01:00
|
|
|
public:
|
2023-01-25 00:54:50 +01:00
|
|
|
MLPPMANN(std::vector<std::vector<double>> inputSet, std::vector<std::vector<double>> outputSet);
|
|
|
|
~MLPPMANN();
|
2023-01-24 19:00:54 +01:00
|
|
|
std::vector<std::vector<double>> modelSetTest(std::vector<std::vector<double>> X);
|
|
|
|
std::vector<double> modelTest(std::vector<double> x);
|
|
|
|
void gradientDescent(double learning_rate, int max_epoch, bool UI = 1);
|
|
|
|
double score();
|
|
|
|
void save(std::string fileName);
|
|
|
|
|
|
|
|
void addLayer(int n_hidden, std::string activation, std::string weightInit = "Default", std::string reg = "None", double lambda = 0.5, double alpha = 0.5);
|
|
|
|
void addOutputLayer(std::string activation, std::string loss, std::string weightInit = "Default", std::string reg = "None", double lambda = 0.5, double alpha = 0.5);
|
|
|
|
|
|
|
|
private:
|
|
|
|
double Cost(std::vector<std::vector<double>> y_hat, std::vector<std::vector<double>> y);
|
|
|
|
void forwardPass();
|
|
|
|
|
|
|
|
std::vector<std::vector<double>> inputSet;
|
|
|
|
std::vector<std::vector<double>> outputSet;
|
|
|
|
std::vector<std::vector<double>> y_hat;
|
|
|
|
|
2023-01-25 00:21:31 +01:00
|
|
|
std::vector<MLPPHiddenLayer> network;
|
2023-01-25 00:54:50 +01:00
|
|
|
MLPPMultiOutputLayer *outputLayer;
|
2023-01-24 19:00:54 +01:00
|
|
|
|
|
|
|
int n;
|
|
|
|
int k;
|
|
|
|
int n_output;
|
|
|
|
};
|
2023-01-24 19:20:18 +01:00
|
|
|
|
2023-01-23 21:13:26 +01:00
|
|
|
|
|
|
|
#endif /* MANN_hpp */
|