cleaning and small change in TransferFunction

This commit is contained in:
2014-12-21 23:02:45 +01:00
parent ed304e0ef2
commit 6337ce98dd
2 changed files with 6 additions and 10 deletions

View File

@@ -124,19 +124,14 @@ void FeedForward::solvePart(float *newSolution, register size_t begin, size_t en
partialSolution=_mm_add_ps(partialSolution,w); partialSolution=_mm_add_ps(partialSolution,w);
} }
register float* memory=this->weights[layer][j]; register float* memory=this->weights[layer][j];
for(register size_t k=0;k<alignedPrev;k+=4) for(register size_t k=0;k<alignedPrev;k+=sizeof(float))
{ {
w = _mm_load_ps(memory+k); w = _mm_load_ps(memory+k);
sols = _mm_load_ps(sol+k); sols = _mm_load_ps(sol+k);
w=_mm_mul_ps(w,sols); w=_mm_mul_ps(w,sols);
partialSolution=_mm_add_ps(partialSolution,w); partialSolution=_mm_add_ps(partialSolution,w);
} }
/* pre-SSE3 solution #ifdef USE_SSE2 //pre-SSE3 solution
__m128 temp = _mm_add_ps(_mm_movehl_ps(foo128, foo128), foo128);
float x;
_mm_store_ss(&x, _mm_add_ss(temp, _mm_shuffle_ps(temp, 1)));
*/
#ifdef USE_SSE2
partialSolution= _mm_add_ps(_mm_movehl_ps(partialSolution, partialSolution), partialSolution); partialSolution= _mm_add_ps(_mm_movehl_ps(partialSolution, partialSolution), partialSolution);
partialSolution=_mm_add_ss(partialSolution, _mm_shuffle_ps(partialSolution,partialSolution, 1)); partialSolution=_mm_add_ss(partialSolution, _mm_shuffle_ps(partialSolution,partialSolution, 1));
#else #else

View File

@@ -12,10 +12,11 @@ namespace TransferFunction
class HyperbolicTangent: public TransferFunction class HyperbolicTangent: public TransferFunction
{ {
public: public:
HyperbolicTangent() {} HyperbolicTangent(const float& lam=1):lambda(lam) {}
inline virtual float derivatedOutput(const float&,const float &output) override { return 1-pow(output,2); } 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(x); }; inline virtual float operator()(const float &x) override { return tanh(lambda*x); };
protected: protected:
float lambda;
}; };
} }
} }