modified BP interface

This commit is contained in:
2016-02-24 19:05:26 +01:00
parent 47de0fa08b
commit c45f12f53c
10 changed files with 195 additions and 13 deletions

View File

@@ -0,0 +1,29 @@
#pragma once
#include "CorrectionFunction.h"
#include <iostream>
namespace NeuralNetwork {
namespace Learning {
namespace CorrectionFunction {
class ArcTangent : public CorrectionFunction {
public:
ArcTangent (const float &c=1.0): coefficient(c) {
}
/**
* @brief operator returns error for values
*
*/
inline virtual float operator()(const float &expected, const float &computed) const override final {
//std::cout << (expected-computed) << ":" << atan(expected-computed) << "\n";
return atan(coefficient*(expected-computed));
}
private:
const float coefficient;
};
}
}
}

View File

@@ -0,0 +1,19 @@
#pragma once
namespace NeuralNetwork {
namespace Learning {
namespace CorrectionFunction {
class CorrectionFunction {
public:
virtual ~ CorrectionFunction() {
}
/**
* @brief operator returns error for values
*
*/
virtual float operator()(const float & expected, const float &computed) const = 0;
};
}
}
}

View File

@@ -0,0 +1,20 @@
#pragma once
#include "CorrectionFunction.h"
namespace NeuralNetwork {
namespace Learning {
namespace CorrectionFunction {
class Linear : public CorrectionFunction {
public:
/**
* @brief operator returns error for values
*
*/
inline virtual float operator()(const float &expected, const float &computed) const override final {
return expected-computed;
}
};
}
}
}

View File

@@ -0,0 +1,22 @@
#pragma once
#include "CorrectionFunction.h"
namespace NeuralNetwork {
namespace Learning {
namespace CorrectionFunction {
class Optical : public CorrectionFunction {
public:
/**
* @brief operator returns error for values
*
*/
inline virtual float operator()(const float &expected, const float &computed) const override final {
register float tmp=(expected-computed);
register float ret=1+exp(tmp*tmp);
return tmp < 0? -ret:ret;
}
};
}
}
}