Newer
Older
//
// Created by martin on 7/15/18.
//
#ifndef INC_4NEURO_ERRORFUNCTION_H
#define INC_4NEURO_ERRORFUNCTION_H
kra568
committed
#include "../settings.h"
#include "../Network/NeuralNetwork.h"
#include "../DataSet/DataSet.h"
Martin Beseda
committed
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
namespace lib4neuro {
enum ErrorFunctionType {
ErrorFuncMSE
};
class ErrorFunction {
public:
/**
*
* @param weights
* @return
*/
virtual double eval(std::vector<double> *weights = nullptr) = 0;
/**
*
* @return
*/
LIB4NEURO_API virtual size_t get_dimension();
protected:
/**
*
*/
size_t dimension = 0;
};
class MSE : public ErrorFunction {
public:
/**
* Constructor for single neural network
* @param net
* @param ds
*/
LIB4NEURO_API MSE(NeuralNetwork *net, DataSet *ds);
/**
*
* @param weights
* @return
*/
LIB4NEURO_API virtual double eval(std::vector<double> *weights = nullptr);
private:
NeuralNetwork *net;
DataSet *ds;
};
class ErrorSum : public ErrorFunction {
public:
/**
*
*/
LIB4NEURO_API ErrorSum();
/**
*
*/
LIB4NEURO_API ~ErrorSum();
/**
*
* @param weights
* @return
*/
LIB4NEURO_API virtual double eval(std::vector<double> *weights = nullptr);
/**
*
* @param F
*/
LIB4NEURO_API void add_error_function(ErrorFunction *F, double alpha = 1.0);
/**
*
* @return
*/
LIB4NEURO_API size_t get_dimension() override;
private:
std::vector<ErrorFunction *> *summand;
std::vector<double> *summand_coefficient;
};
}
#endif //INC_4NEURO_ERRORFUNCTION_H