ActivationFunctions { public static final float sigmoidPrime(final float y) { return y*(1-y); } 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);  }
@Test public void testSigmoidPrime() { float[] x = {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}; float[] y = {0.000910221f, 0.00100576f, 0.0011113f, 0.00122789f, 0.00135667f, 0.00149893f, 0.00165605f, 0.00182958f, 0.00202122f, 0.00223284f, 0.00246651f, 0.00272449f, 0.0030093f, 0.00332368f, 0.00367066f, 0.00405357f, 0.00447605f, 0.00494212f, 0.00545619f, 0.00602307f, 0.00664804f, 0.00733689f, 0.00809593f, 0.00893204f, 0.00985274f, 0.0108662f, 0.0119813f, 0.0132077f, 0.0145557f, 0.0160367f, 0.0176627f, 0.0194466f, 0.0214024f, 0.0235448f, 0.0258895f, 0.0284529f, 0.0312524f, 0.0343058f, 0.0376316f, 0.0412489f, 0.0451765f, 0.0494334f, 0.0540379f, 0.0590075f, 0.0643581f, 0.0701035f, 0.0762547f, 0.0828193f, 0.0898f, 0.0971944f, 0.104993f, 0.11318f, 0.121729f, 0.130605f, 0.139763f, 0.149146f, 0.158684f, 0.168298f, 0.177894f, 0.187369f, 0.196611f, 0.2055f, 0.213909f, 0.221712f, 0.228784f, 0.235003f, 0.24026f, 0.244458f, 0.247516f, 0.249376f, 0.25f, 0.249376f, 0.247517f, 0.244459f, 0.240261f, 0.235004f, 0.228785f, 0.221713f, 0.21391f, 0.205501f, 0.196613f, 0.187371f, 0.177895f, 0.168299f, 0.158686f, 0.149147f, 0.139765f, 0.130607f, 0.12173f, 0.113181f, 0.104994f, 0.0971954f, 0.089801f, 0.0828201f, 0.0762556f, 0.0701043f, 0.0643588f, 0.0590082f, 0.0540386f, 0.049434f, 0.045177f, 0.0412494f, 0.0376321f, 0.0343062f, 0.0312528f, 0.0284533f, 0.0258898f, 0.0235451f, 0.0214027f, 0.0194469f, 0.0176629f, 0.0160369f, 0.0145559f, 0.0132078f, 0.0119815f, 0.0108664f, 0.00985287f, 0.00893215f, 0.00809603f, 0.00733699f, 0.00664813f, 0.00602315f, 0.00545626f, 0.00494219f, 0.00447611f, 0.00405362f, 0.00367071f, 0.00332373f, 0.00300934f, 0.00272453f, 0.00246654f, 0.00223287f, 0.00202124f, 0.0018296f, 0.00165607f, 0.00149895f, 0.00135669f, 0.0012279f, 0.00111131f, 0.00100577f, 0.000910233f}; for (int i = 0; i < x.length; i++) { float expResult = y[i]; float result = ActivationFunctions.sigmoidPrime(x[i]); assertEquals(expResult, result, 1e-6); } }