@Test public void testSigmoid() { float[] x = {-7.0f, -6.9f, -6.8f, -6.7f, -6.6f, -6.5f, -6.4f, -6.3f, -6.2f, -6.1f, -6.0f, -5.9f, -5.8f, -5.7f, -5.6f, -5.5f, -5.4f, -5.3f, -5.2f, -5.1f, -5.0f, -4.9f, -4.8f, -4.7f, -4.6f, -4.5f, -4.4f, -4.3f, -4.2f, -4.1f, -4.0f, -3.9f, -3.8f, -3.7f, -3.6f, -3.5f, -3.4f, -3.3f, -3.2f, -3.1f, -3.0f, -2.9f, -2.8f, -2.7f, -2.6f, -2.5f, -2.4f, -2.3f, -2.2f, -2.1f, -2.0f, -1.9f, -1.8f, -1.7f, -1.6f, -1.5f, -1.4f, -1.3f, -1.2f, -1.1f, -1.0f, -0.9f, -0.8f, -0.7f, -0.6f, -0.5f, -0.4f, -0.3f, -0.2f, -0.1f, 0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.1f, 2.2f, 2.3f, 2.4f, 2.5f, 2.6f, 2.7f, 2.8f, 2.9f, 3.0f, 3.1f, 3.2f, 3.3f, 3.4f, 3.5f, 3.6f, 3.7f, 3.8f, 3.9f, 4.0f, 4.1f, 4.2f, 4.3f, 4.4f, 4.5f, 4.6f, 4.7f, 4.8f, 4.9f, 5.0f, 5.1f, 5.2f, 5.3f, 5.4f, 5.5f, 5.6f, 5.7f, 5.8f, 5.9f, 6.0f, 6.1f, 6.2f, 6.3f, 6.4f, 6.5f, 6.6f, 6.7f, 6.8f, 6.9f, 7.0f}; float[] y = {0.000911051f, 0.00100677f, 0.00111254f, 0.0012294f, 0.00135852f, 0.00150118f, 0.0016588f, 0.00183294f, 0.00202532f, 0.00223785f, 0.00247262f, 0.00273196f, 0.00301841f, 0.0033348f, 0.00368424f, 0.00407013f, 0.00449627f, 0.00496679f, 0.00548629f, 0.00605979f, 0.00669284f, 0.00739153f, 0.00816255f, 0.00901328f, 0.00995178f, 0.0109869f, 0.0121284f, 0.0133869f, 0.014774f, 0.0163025f, 0.0179862f, 0.0198402f, 0.0218812f, 0.0241269f, 0.0265969f, 0.0293121f, 0.0322954f, 0.0355711f, 0.0391656f, 0.0431071f, 0.0474257f, 0.0521534f, 0.057324f, 0.0629731f, 0.0691381f, 0.0758579f, 0.0831724f, 0.0911226f, 0.0997501f, 0.109096f, 0.119202f, 0.130108f, 0.14185f, 0.154465f, 0.167981f, 0.182425f, 0.197815f, 0.214164f, 0.231474f, 0.249739f, 0.26894f, 0.289049f, 0.310024f, 0.331811f, 0.354342f, 0.377539f, 0.401311f, 0.425556f, 0.450164f, 0.475019f, 0.499998f, 0.524978f, 0.549832f, 0.574441f, 0.598686f, 0.622458f, 0.645655f, 0.668186f, 0.689973f, 0.710948f, 0.731057f, 0.750259f, 0.768523f, 0.785834f, 0.802183f, 0.817573f, 0.832017f, 0.845534f, 0.858148f, 0.869891f, 0.880796f, 0.890902f, 0.900249f, 0.908876f, 0.916827f, 0.924141f, 0.930861f, 0.937026f, 0.942675f, 0.947846f, 0.952574f, 0.956892f, 0.960834f, 0.964428f, 0.967704f, 0.970688f, 0.973403f, 0.975873f, 0.978118f, 0.98016f, 0.982014f, 0.983697f, 0.985226f, 0.986613f, 0.987871f, 0.989013f, 0.990048f, 0.990987f, 0.991837f, 0.992608f, 0.993307f, 0.99394f, 0.994514f, 0.995033f, 0.995504f, 0.99593f, 0.996316f, 0.996665f, 0.996982f, 0.997268f, 0.997527f, 0.997762f, 0.997975f, 0.998167f, 0.998341f, 0.998499f, 0.998641f, 0.998771f, 0.998887f, 0.998993f, 0.999089f}; for (int i = 0; i < x.length; i++) { float expResult = y[i]; float result = ActivationFunctions.sigmoid(x[i]); assertEquals(expResult, result, 1e-5); } }
public static final float sigmoid(final float x) { return 1 / (1 + (float)Math.exp(-x)); }
ActivationFunctions { public static final float sigmoid(final float x) { return 1 / (1 + (float)Math.exp(-x)); } }
ActivationFunctions { public static final float sigmoid(final float x) { return 1 / (1 + (float)Math.exp(-x)); } private  ActivationFunctions(); }
ActivationFunctions { public static final float sigmoid(final float x) { return 1 / (1 + (float)Math.exp(-x)); } private  ActivationFunctions(); static final float calc(final ActivationType type, final float x); static final float prime(ActivationType type, float y); static final float sigmoid(final float x); static final float sigmoidPrime(final float y); static final float tanh(final float x); static final float tanhPrime(final float y); static final float relu(final float x); static final float reluPrime(final float y); static final float linear(final float x); static final float linearPrime(final float y); }
ActivationFunctions { public static final float sigmoid(final float x) { return 1 / (1 + (float)Math.exp(-x)); } private  ActivationFunctions(); static final float calc(final ActivationType type, final float x); static final float prime(ActivationType type, float y); static final float sigmoid(final float x); static final float sigmoidPrime(final float y); static final float tanh(final float x); static final float tanhPrime(final float y); static final float relu(final float x); static final float reluPrime(final float y); static final float linear(final float x); static final float linearPrime(final float y);  }