Commit bbdcff15 authored by Michal Kravcenko's avatar Michal Kravcenko
Browse files

-added a support for multi-network systems sharing edge weights

-added an example testing multi-network error function
parent dfaf4073
......@@ -42,3 +42,30 @@ double MSE::eval(double *weights) {
return error/n_elements;
}
MSE_SUM::MSE_SUM() {
this->summand = nullptr;
}
MSE_SUM::~MSE_SUM(){
if( this->summand ){
delete this->summand;
}
}
double MSE_SUM::eval(double *weights) {
double output = 0.0;
for(ErrorFunction *f: *this->summand){
output += f->eval( weights );
}
return output;
}
void MSE_SUM::add_error_function(ErrorFunction *F) {
if(!this->summand){
this->summand = new std::vector<ErrorFunction*>(0);
}
this->summand->push_back(F);
}
\ No newline at end of file
......@@ -42,12 +42,6 @@ public:
*/
MSE(NeuralNetwork* net, DataSet* ds);
/**
* Constructor for multiple error functions, which will get summed up
* @param func_vec
*/
//MSE(std::vector<ErrorFunction> func_vec);
/**
*
* @param weights
......@@ -61,5 +55,34 @@ private:
DataSet* ds;
};
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;
};
#endif //INC_4NEURO_ERRORFUNCTION_H
/**
* DESCRIPTION OF THE FILE
*
* @author Michal Kravčenko
* @date 4.7.18 -
*/
#include "FunctionBase.h"
FunctionBase::FunctionBase() {}
FunctionBase::~FunctionBase() {
}
/**
* DESCRIPTION OF THE FILE
*
* @author Michal Kravčenko
* @date 4.7.18 -
*/
#ifndef INC_4NEURO_FUNCTIONBASE_H
#define INC_4NEURO_FUNCTIONBASE_H
class FunctionBase {
public:
FunctionBase();
virtual ~FunctionBase();
virtual double eval(double x) = 0;
virtual FunctionBase* get_derivative() = 0;
protected:
FunctionBase* derivative = nullptr;
private:
};
#endif //INC_4NEURO_FUNCTIONBASE_H
/**
* DESCRIPTION OF THE FILE
*
* @author Michal Kravčenko
* @date 4.7.18 -
*/
#include "FunctionCosine.h"
FunctionCosine::FunctionCosine(double period, double bias) {
this->period = period;
this->bias = bias;
}
double FunctionCosine::eval(double x) {
return std::cos(x * this->period + this->bias);
}
FunctionBase* FunctionCosine::get_derivative() {
if(!this->derivative){
this->derivative = new FunctionSine();
}
return this->derivative;
}
\ No newline at end of file
/**
* DESCRIPTION OF THE FILE
*
* @author Michal Kravčenko
* @date 4.7.18 -
*/
#ifndef INC_4NEURO_FUNCTIONCOSINE_H
#define INC_4NEURO_FUNCTIONCOSINE_H
#include <cmath>
#include "FunctionBase.h"
#include "FunctionSine.h"
class FunctionCosine: FunctionBase {
public:
FunctionCosine(double period, double bias);
double eval(double x);
FunctionBase* get_derivative();
private:
double period = 0.0;
double bias = 0.0;
};
#endif //INC_4NEURO_FUNCTIONCOSINE_H
/**
* DESCRIPTION OF THE FILE
*
* @author Michal Kravčenko
* @date 4.7.18 -
*/
#include "FunctionExponential.h"
/**
* DESCRIPTION OF THE FILE
*
* @author Michal Kravčenko
* @date 4.7.18 -
*/
#ifndef INC_4NEURO_FUNCTIONEXPONENTIAL_H
#define INC_4NEURO_FUNCTIONEXPONENTIAL_H
#include "FunctionBase.h"
class FunctionExponential: FunctionBase {
};
#endif //INC_4NEURO_FUNCTIONEXPONENTIAL_H
/**
* DESCRIPTION OF THE FILE
*
* @author Michal Kravčenko
* @date 4.7.18 -
*/
#include "FunctionLogarithm.h"
/**
* DESCRIPTION OF THE FILE
*
* @author Michal Kravčenko
* @date 4.7.18 -
*/
#ifndef INC_4NEURO_FUNCTIONLOGARITHM_H
#define INC_4NEURO_FUNCTIONLOGARITHM_H
#include "FunctionBase.h"
class FunctionLogarithm: FunctionBase {
};
#endif //INC_4NEURO_FUNCTIONLOGARITHM_H
/**
* DESCRIPTION OF THE FILE
*
* @author Michal Kravčenko
* @date 4.7.18 -
*/
#include "FunctionPolynomial.h"
/**
* DESCRIPTION OF THE FILE
*
* @author Michal Kravčenko
* @date 4.7.18 -
*/
#ifndef INC_4NEURO_FUNCTIONPOLYNOMIAL_H
#define INC_4NEURO_FUNCTIONPOLYNOMIAL_H
#include "FunctionBase.h"
class FunctionPolynomial: FunctionBase {
};
#endif //INC_4NEURO_FUNCTIONPOLYNOMIAL_H
/**
* DESCRIPTION OF THE FILE
*
* @author Michal Kravčenko
* @date 4.7.18 -
*/
#include "FunctionSine.h"
/**
* DESCRIPTION OF THE FILE
*
* @author Michal Kravčenko
* @date 4.7.18 -
*/
#ifndef INC_4NEURO_FUNCTIONSINE_H
#define INC_4NEURO_FUNCTIONSINE_H
#include "FunctionBase.h"
class FunctionSine: FunctionBase {
};
#endif //INC_4NEURO_FUNCTIONSINE_H
/**
* DESCRIPTION OF THE FILE
*
* @author Michal Kravčenko
* @date 4.7.18 -
*/
#include "Graph.h"
/**
* DESCRIPTION OF THE FILE
*
* @author Michal Kravčenko
* @date 4.7.18 -
*/
#ifndef INC_4NEURO_GRAPH_H
#define INC_4NEURO_GRAPH_H
//TODO verification of decision making (for each input determine the magnitude of its influence over the output)
//TODO form a graph of the inverse function
class Graph {
};
#endif //INC_4NEURO_GRAPH_H
/**
* DESCRIPTION OF THE FILE
*
* @author Michal Kravčenko
* @date 4.7.18 -
*/
#include "VertexBase.h"
/**
* DESCRIPTION OF THE FILE
*
* @author Michal Kravčenko
* @date 4.7.18 -
*/
#ifndef INC_4NEURO_VERTEXBASE_H
#define INC_4NEURO_VERTEXBASE_H
class VertexBase {
};
#endif //INC_4NEURO_VERTEXBASE_H
/**
* DESCRIPTION OF THE FILE
*
* @author Michal Kravčenko
* @date 4.7.18 -
*/
#include "VertexCompound.h"
/**
* DESCRIPTION OF THE FILE
*
* @author Michal Kravčenko
* @date 4.7.18 -
*/
#ifndef INC_4NEURO_VERTEXCOMPOUND_H
#define INC_4NEURO_VERTEXCOMPOUND_H
class VertexCompound {
};
#endif //INC_4NEURO_VERTEXCOMPOUND_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment