Neural
network.h
Go to the documentation of this file.
1 
9 #ifndef NETWORK_H
10 #define NETWORK_H
11 
12 #include <iostream>
13 #include <stdlib.h>
14 #include <eigen3/Eigen/Dense>
15 #include <vector>
16 #include <string>
17 #include <chrono>
18 #include <fstream>
19 #include <jsoncpp/json/json.h>
20 #include <jsoncpp/json/writer.h>
21 #include <sciplot/sciplot.hpp>
22 #include <omp.h>
23 #include <thread>
24 #include "layers/layer.h"
25 #include "layers/fc_layer.h"
27 #include "loss.h"
28 
29 namespace Neural
30 {
31  class Network
32  {
33  public:
34  Network();
35  Network(std::string); //for load prexisting network
36  ~Network();
37 
38  void Add(Layer *layer);
39  void Fit(Eigen::MatrixXd x_train, Eigen::MatrixXd y_train, int epochs, double learning_rate, int batch_size);
40  void Use(Loss *l);
41  void Evaluate(Eigen::MatrixXd y_tests, Eigen::MatrixXd y_true);
42 
43  std::vector<Eigen::MatrixXd> Predict(Eigen::MatrixXd input_data);
44  bool Save(std::string);
45  void Load(std::string);
46  void SetThreads(int thread);
47  int GetThreads();
48 
49 
50  private:
51  Loss* m_loss;
52  std::vector<Layer*> m_layer;
53  std::vector<double> m_error;
54  std::ofstream file;
55  void PlotData(int epoch, std::vector<double> error);
56 
57  };
58 }
59 #endif
Neural::Network::Save
bool Save(std::string)
Definition: network.cpp:167
Neural::Network::Network
Network()
Constructor of Network class.
Definition: network.cpp:30
Neural::Network::Predict
std::vector< Eigen::MatrixXd > Predict(Eigen::MatrixXd input_data)
Definition: network.cpp:81
Neural::Network::Use
void Use(Loss *l)
Definition: network.cpp:71
layer.h
This class is the Base class for all Layers types.
Neural::Network
Definition: network.h:31
Neural::Network::Add
void Add(Layer *layer)
Definition: network.cpp:61
Neural::Network::Evaluate
void Evaluate(Eigen::MatrixXd y_tests, Eigen::MatrixXd y_true)
Definition: network.cpp:156
Neural::Network::GetThreads
int GetThreads()
Definition: network.cpp:261
activation_layer.h
This class is the Base class for all activation types.
fc_layer.h
This class allows the creation of a full connected (Dense) layer.
Neural::Network::Load
void Load(std::string)
Definition: network.cpp:192
Neural::Network::Fit
void Fit(Eigen::MatrixXd x_train, Eigen::MatrixXd y_train, int epochs, double learning_rate, int batch_size)
Definition: network.cpp:111
Neural::Network::SetThreads
void SetThreads(int thread)
Definition: network.cpp:256
Neural::Layer
Definition: layer.h:18
Neural::Loss
Definition: loss.h:12
loss.h
Neural::Network::~Network
~Network()
Definition: network.cpp:49
Neural
Definition: activation.h:10