added another activation function, plus minor cleanup
This commit is contained in:
1 parent
eedade5b63
commit
898adda122
1 file changed
+4
-2
+4
-2
@@ -15,7 +15,8 @@ double TargetFunction(double x)
|
||||
//return exp(-x*x); // gaussian
|
||||
//return tanh(x); // tanh
|
||||
//return (2.0/(1.0+exp(-x))-1.0); // tanh approximation
|
||||
return (x<0.0 ? -1.0 : 1.0) * sqrt(abs(x)); // signed root
|
||||
//return (x<0.0 ? -1.0 : 1.0) * sqrt(abs(x)); // signed root
|
||||
return sin(x); // sin
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +52,8 @@ class PolySearch: public DE::Engine<NUM_COEFFICIENTS>
|
||||
double actual = TargetFunction(i);
|
||||
|
||||
// accumulate error^2
|
||||
error += (test-actual)*(test-actual);
|
||||
double e = test - actual;
|
||||
error += e * e;
|
||||
|
||||
// inc test count (divisor to get from SE to MSE)
|
||||
test_count++;
|
||||
|
||||
Reference in new issue
Block a user