This patch improves the computation of tanh.
Rather than calling tanh fuction, it is faster when
sigmoid is used.
tanh(x) = 2.0*sigmoid(2.0*x) -1.0;
**Self evaluation:**
1. Build test: [X]Passed [ ]Failed [ ]Skipped
2. Run test: [X]Passed [ ]Failed [ ]Skipped
Signed-off-by: jijoong.moon <jijoong.moon@samsung.com>
return x * (1.0f - x);
}
-float ActiFunc::tanhFloat(float x) { return (float)tanh(x); }
+float ActiFunc::tanhFloat(float x) {
+ // return (float)tanh(x); Using sigmoid implementaion for latency reason.
+ return 2.0 * sigmoid(2.0 * x) - 1.0;
+}
float ActiFunc::tanhPrime(float x) {
// float th = (float)tanh(x);