reffactored and recurrent implementation
This commit is contained in:
27
include/NeuralNetwork/ActivationFunction/HyperbolicTangent.h
Normal file
27
include/NeuralNetwork/ActivationFunction/HyperbolicTangent.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include "./ActivationFunction.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace NeuralNetwork {
|
||||
namespace ActivationFunction {
|
||||
|
||||
class HyperbolicTangent: public ActivationFunction {
|
||||
public:
|
||||
HyperbolicTangent(const float& lam=1):lambda(lam) {}
|
||||
inline virtual float derivatedOutput(const float&,const float &output) override { return lambda*(1-output*output); }
|
||||
inline virtual float operator()(const float &x) override { return tanh(lambda*x); };
|
||||
virtual ActivationFunction* clone() const override {
|
||||
return new HyperbolicTangent(lambda);
|
||||
}
|
||||
|
||||
virtual std::string stringify() const override {
|
||||
return "{ \"class\": \"NeuralNetwork::ActivationFunction::HyperbolicTangent\", \"lamba\" : "+std::to_string(lambda)+"}";
|
||||
}
|
||||
|
||||
protected:
|
||||
float lambda;
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user