コード例 #1
0
    public void PropagateForwardTest()
    {
        /*SystemRandomSource rndGenerator = new SystemRandomSource(seed);
         * ContinuousUniform cu = new ContinuousUniform(-initialValueWeights, initialValueWeights, rndGenerator);
         */
        Vector <float> data = Vector <float> .Build.DenseOfArray(new float[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 });;
        int            iter = 50000;


        var watch = System.Diagnostics.Stopwatch.StartNew();

        for (int i = 0; i < iter; i++)
        {
            //data = Vector<float>.Build.DenseOfArray(new float[]  { i, i + 1, i + 2, i + 3, i + 4, i + 5  });
            mlpMN.PropagateForward2(data);
        }
        watch.Stop();
        var elapsedMs = watch.ElapsedMilliseconds;

        Debug.Log("MathNet Falk Array : " + elapsedMs);



        watch = System.Diagnostics.Stopwatch.StartNew();
        for (int i = 0; i < iter; i++)
        {
            mlpMN.PropagateForward(data);
        }
        watch.Stop();
        elapsedMs = watch.ElapsedMilliseconds;

        Debug.Log("MathNet Multiply: " + elapsedMs);

        watch = System.Diagnostics.Stopwatch.StartNew();
        for (int i = 0; i < iter; i++)
        {
            mlpMN.PropagateForward(data, true);
        }
        watch.Stop();
        elapsedMs = watch.ElapsedMilliseconds;

        Debug.Log("MathNet Falk Matrix: " + elapsedMs);



        float[,] dataArr = new float[, ] {
            { 1, 2, 3, 4, 5, 6, 7, 8, 9 }
        };
        watch = System.Diagnostics.Stopwatch.StartNew();
        for (int i = 0; i < iter; i++)
        {
            mlp.PropagateForward(dataArr);
        }
        watch.Stop();
        elapsedMs = watch.ElapsedMilliseconds;

        Debug.Log("Array Falk Array: " + elapsedMs);
        //mlpMN.PropagateForward2(data);
    }
コード例 #2
0
        public void Stabilization()
        {
            Rigidbody rigid = drone.GetComponent <MainBoard>().GetComponentInChildren <Rigidbody>();

            //Debug.Log(drone.GetComponent<MainBoard>().inputMLP);

            /*drone.GetComponent<MainBoard>().deltaPosition = new Vector3(rigid.transform.localPosition.x - drone.GetComponent<MainBoard>().initDeltaPosition.x, rigid.transform.localPosition.y - drone.GetComponent<MainBoard>().initDeltaPosition.y, rigid.transform.localPosition.z - drone.GetComponent<MainBoard>().initDeltaPosition.z);
             * drone.GetComponent<MainBoard>().mlp.PropagateForward(drone.GetComponent<MainBoard>().inputMLP);*/
            taskObject.UCSignal(rigid, targetPosition);
            //Debug.Log(taskObject.signal.input);
            mlp.PropagateForward(taskObject.signal.input, true);
            //Debug.Log(mlp.layers[taskObject.shapes.Count - 1]);
            signalControl.Throttle = mlp.layers[taskObject.shapes.Count - 1][3, 0];
            signalControl.Rudder   = mlp.layers[taskObject.shapes.Count - 1][0, 0];
            signalControl.Elevator = mlp.layers[taskObject.shapes.Count - 1][1, 0];
            signalControl.Aileron  = mlp.layers[taskObject.shapes.Count - 1][2, 0];
            Debug.Log(mlp.weights[0]);
            drone.GetComponent <MainBoard>().SendControlSignal(signalControl);
        }