ErrorFunctions.h 1.17 KB
Newer Older
1 2 3 4 5 6 7
//
// Created by martin on 7/15/18.
//

#ifndef INC_4NEURO_ERRORFUNCTION_H
#define INC_4NEURO_ERRORFUNCTION_H

Martin Beseda's avatar
Martin Beseda committed
8 9
#include "../Network/NeuralNetwork.h"
#include "../DataSet/DataSet.h"
10 11

class ErrorFunction {
Martin Beseda's avatar
Martin Beseda committed
12 13 14 15 16 17 18 19
public:

    /**
     *
     * @param weights
     * @return
     */
    virtual double eval(double* weights) = 0;
20
    
Martin Beseda's avatar
Martin Beseda committed
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
    /**
     * 
     * @return 
     */
    virtual size_t get_dimension();

protected:

    /**
     *
     */
    size_t dimension;
};

class MSE : public ErrorFunction {

public:
    /**
     * Constructor for single neural network
     * @param net
     * @param ds
     */
    MSE(NeuralNetwork* net, DataSet* ds);

    /**
     *
     * @param weights
     * @return
     */
    virtual double eval(double* weights);

private:

    NeuralNetwork* net;
    DataSet* ds;
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
class MSE_SUM : ErrorFunction{
public:
    /**
     *
     */
    MSE_SUM();

    /**
     *
     */
    ~MSE_SUM();

    /**
     *
     * @param weights
     * @return
     */
    virtual double eval(double* weights);

    /**
     *
     * @param F
     */
    void add_error_function(ErrorFunction *F);

private:
    std::vector<ErrorFunction*> *summand;
};

87 88

#endif //INC_4NEURO_ERRORFUNCTION_H