modified BP interface
This commit is contained in:
@@ -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;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
20
include/NeuralNetwork/Learning/CorrectionFunction/Linear.h
Normal file
20
include/NeuralNetwork/Learning/CorrectionFunction/Linear.h
Normal 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;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
22
include/NeuralNetwork/Learning/CorrectionFunction/Optical.h
Normal file
22
include/NeuralNetwork/Learning/CorrectionFunction/Optical.h
Normal 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;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user