activation funcion: delete streaming
This commit is contained in:
@@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include "./StreamingActivationFunction.h"
|
#include "./ActivationFunction.h"
|
||||||
#include "../../sse_mathfun.h"
|
|
||||||
|
|
||||||
namespace NeuralNetwork {
|
namespace NeuralNetwork {
|
||||||
namespace ActivationFunction {
|
namespace ActivationFunction {
|
||||||
@@ -12,19 +11,14 @@ namespace ActivationFunction {
|
|||||||
* @author Tomas Cernik (Tom.Cernik@gmail.com)
|
* @author Tomas Cernik (Tom.Cernik@gmail.com)
|
||||||
* @brief Class for computing sigmoid
|
* @brief Class for computing sigmoid
|
||||||
*/
|
*/
|
||||||
class Sigmoid: public StreamingActivationFunction {
|
class Sigmoid: public ActivationFunction {
|
||||||
public:
|
public:
|
||||||
Sigmoid(const float lambdaP = -0.5): lambda(lambdaP) {}
|
Sigmoid(const float lambdaP = -0.5): lambda(lambdaP) {}
|
||||||
|
|
||||||
|
|
||||||
inline virtual float derivatedOutput(const float &, const float &output) const override { return -lambda*output*(1.0f-output); }
|
inline virtual float derivatedOutput(const float &, const float &output) const override { return -lambda*output*(1.0f-output); }
|
||||||
|
|
||||||
inline virtual float operator()(const float &x) const override { return 1.0f / (1.0f +exp(lambda*x) ); };
|
inline virtual float operator()(const float &x) const override { return 1.0f / (1.0f +exp(lambda*x) ); };
|
||||||
|
|
||||||
inline virtual __m128 operator()(const __m128 &x) const override {
|
|
||||||
// exp_ps is extremly slow!
|
|
||||||
return _mm_div_ps(_mm_set1_ps(1.0),_mm_add_ps(exp_ps(_mm_mul_ps(_mm_set1_ps(lambda),x)),_mm_set1_ps(1.0)));
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ActivationFunction* clone() const override {
|
virtual ActivationFunction* clone() const override {
|
||||||
return new Sigmoid(lambda);
|
return new Sigmoid(lambda);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <xmmintrin.h>
|
|
||||||
|
|
||||||
#include "./ActivationFunction.h"
|
|
||||||
|
|
||||||
namespace NeuralNetwork {
|
|
||||||
namespace ActivationFunction {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Tomas Cernik (Tom.Cernik@gmail.com)
|
|
||||||
* @brief Abstract class of activation function with support of SSE
|
|
||||||
*/
|
|
||||||
class StreamingActivationFunction : public ActivationFunction {
|
|
||||||
public:
|
|
||||||
using ActivationFunction::operator();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Returns value of four outputs
|
|
||||||
* @param x is float[4], in every array value can be stored
|
|
||||||
*/
|
|
||||||
virtual __m128 operator()(const __m128 &x) const=0;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user