44   if (arg > 4.97) 
return 1;
 
   45   if (arg < -4.97) 
return -1;
 
   46   float arg2 = arg * arg;
 
   47   float a = arg * (135135.0f + arg2 * (17325.0f + arg2 * (378.0f + arg2)));
 
   48   float b = 135135.0f + arg2 * (62370.0f + arg2 * (3150.0f + arg2 * 28.0f));
 
   75   TString expr = 
"tanh(x)\t\t (1-tanh()^2)";
 
   85      fout << 
"double " << fncName << 
"(double x) const {" << std::endl;
 
   86      fout << 
"   // fast hyperbolic tan approximation" << std::endl;
 
   87      fout << 
"   if (x > 4.97) return 1;" << std::endl;
 
   88      fout << 
"   if (x < -4.97) return -1;" << std::endl;
 
   89      fout << 
"   float x2 = x * x;" << std::endl;
 
   90      fout << 
"   float a = x * (135135.0f + x2 * (17325.0f + x2 * (378.0f + x2)));" << std::endl;
 
   91      fout << 
"   float b = 135135.0f + x2 * (62370.0f + x2 * (3150.0f + x2 * 28.0f));" << std::endl;
 
   92      fout << 
"   return a / b;" << std::endl;
 
   93      fout << 
"}" << std::endl;
 
   95      fout << 
"double " << fncName << 
"(double x) const {" << std::endl;
 
   96      fout << 
"   // hyperbolic tan" << std::endl;
 
   97      fout << 
"   return tanh(x);" << std::endl;
 
   98      fout << 
"}" << std::endl;
 
Tanh activation function for ANN.
 
TString GetExpression()
get expressions for the tanh and its derivative whatever that may be good for ...
 
Double_t Eval(Double_t arg)
evaluate the tanh
 
Double_t fast_tanh(Double_t arg)
a fast tanh approximation
 
Double_t EvalDerivative(Double_t arg)
evaluate the derivative
 
virtual void MakeFunction(std::ostream &fout, const TString &fncName)
writes the Tanh sigmoid activation function source code
 
Double_t TanH(Double_t)
Returns the hyperbolic tangent of x.