示例#1
0
    void data_test()
    {
        float[] test = new float[2] {
            0, 0
        };
        float[] test2 = new float[2] {
            0, 1
        };
        float[] test3 = new float[2] {
            1, 0
        };
        float[] test4 = new float[2] {
            1, 1
        };

        float[] predict = nn.predict(test);
        //float[] predict2 = nn.predict(test2);
        //float[] predict3 = nn.predict(test3);
        //float[] predict4 = nn.predict(test4);

        Debug.Log("output data test");

        Debug.Log(predict[0]);
        //Debug.Log(predict2[0]);
        //Debug.Log(predict3[0]);
        //Debug.Log(predict4[0]);
    }
示例#2
0
    /**
     * test the data with XOR input
     * */

    void data_test()
    {
        float[] test1 = new float[2] {
            0, 0
        };
        float[] test2 = new float[2] {
            0, 1
        };
        float[] test3 = new float[2] {
            1, 0
        };
        float[] test4 = new float[2] {
            1, 1
        };

        float[] predict1 = nn.predict(test1);
        float[] predict2 = nn.predict(test2);
        float[] predict3 = nn.predict(test3);
        float[] predict4 = nn.predict(test4);

        Debug.Log("output data test");

        //Debug.Log(predict1[0]); // output should be 0 ( false )
        //Debug.Log(predict2[0]);  // output should be 1 ( true )
        //Debug.Log(predict3[0]);  // output should be 1 ( true )
        //Debug.Log(predict4[0]);  // output should be 0 ( false )


        /**
         * NOTE: if the output data got stuck beetwen 4 and 5 for a long time, restart train data
         *
         * cause: random weight input wasn't good.
         * */

        // if predict output[0] is less then 0.01 / false, then done
        if (predict1[0] < 0.01)
        {
            Debug.Log("Done");
        }
        else
        {
            Debug.Log(predict1[0]);
        }
    }