Ejemplo n.º 1
0
        void log(StreamWriter logFile, int recordingCount, bool learning, int world)
        {
            //Dictionary<Signal, double[,]> fullPrediction = CA3.Predict( CA3.modalities ); //Evaluate with all modalities
            //c0sacc->c1
            Dictionary <Signal, double[, ]> c1Pred = CA3.Predict(new List <CDZNET.Core.Signal>()
            {
                LEC_ColorT0, MEC
            });
            //c1sacc->c0
            Dictionary <Signal, double[, ]> c0Pred = CA3.Predict(new List <CDZNET.Core.Signal>()
            {
                LEC_ColorT1, MEC
            });
            //c0c1->sacc
            Dictionary <Signal, double[, ]> saccPred = CA3.Predict(new List <CDZNET.Core.Signal>()
            {
                LEC_ColorT0, LEC_ColorT1
            });

            pictureBoxEndPoint.Image          = getBitmapFromColorCode(LEC_ColorT1.reality);
            pictureBoxPredictedEndpoint.Image = getBitmapFromColorCode(c1Pred[LEC_ColorT1]);
            pictureBoxEndPoint.Refresh();
            pictureBoxPredictedEndpoint.Refresh();
            Dictionary <string, double> directionalErrors = getDirectionalErrors(LEC_ColorT1.reality, c1Pred[LEC_ColorT1]);

            if (logFile != null)
            {
                logFile.WriteLine(
                    recordingCount + "," +
                    learning + "," +
                    world + "," +
                    GetString(LEC_ColorT0.reality) + "," +
                    GetString(LEC_ColorT1.reality) + "," +
                    GetString(MEC.reality) + "," +
                    GetString(c1Pred[LEC_ColorT1]) + "," +
                    GetString(GetSquaredError(LEC_ColorT1.reality, c1Pred[LEC_ColorT1])) + "," +
                    directionalErrors["left"] + "," +
                    directionalErrors["top"] + "," +
                    directionalErrors["right"] + "," +
                    directionalErrors["bottom"]
                    //GetSumSquared(c1Pred[LEC_ColorT1], LEC_ColorT1.reality) + "," +
                    //GetString(c0Pred[LEC_ColorT0]) + "," +
                    //GetSumSquared(c0Pred[LEC_ColorT0], LEC_ColorT0.reality) + "," +
                    //GetString(saccPred[MEC]) + "," +
                    //GetSumSquared(saccPred[MEC], MEC.reality)
                    );

                logFile.Flush();
            }
        }
Ejemplo n.º 2
0
        void predictEgosphere()
        {
            CA3.learningLocked = true;
            World predictedWorld = new World(world.Width, world.Height);

            progressBarCurrentOp.Value   = 0;
            progressBarCurrentOp.Minimum = 0;
            progressBarCurrentOp.Maximum = world.Width * world.Height;
            progressBarCurrentOp.Step    = 1;
            //We test the predictions of MEC only
            for (int x = 0; x < world.Width; x++)
            {
                for (int y = 0; y < world.Height; y++)
                {
                    predictedWorld.cells[x, y] = new Cell();
                    //if (x >= retinaSize / 2 && x < world.Width - retinaSize / 2 && y >= retinaSize / 2 && y < world.Height - retinaSize / 2)
                    {
                        Array.Clear(MEC.reality, 0, MEC.reality.Length);
                        MEC.reality[x, 0] = 1.0;
                        MEC.reality[world.Width + y, 0] = 1.0;
                        Dictionary <Signal, double[, ]> prediction = CA3.Predict(new List <Signal> {
                            MEC
                        });

                        //We use only the center as the prediction

                        double[] orientationCode = new double[2]
                        {
                            prediction[LEC_Orientation][(retinaSize / 2) * 2, retinaSize / 2],
                            prediction[LEC_Orientation][(retinaSize / 2) * 2 + 1, retinaSize / 2]
                        };

                        predictedWorld.cells[x, y].orientation = Cell.getOrientationFromCode(orientationCode);

                        for (int compo = 0; compo < 4; compo++)
                        {
                            predictedWorld.cells[x, y].colorCode[compo] = prediction[LEC_Color][(retinaSize / 2) * 4 + compo, retinaSize / 2];
                        }

                        //predictedWorld.cells[x, y].frequency
                        progressBarCurrentOp.PerformStep();
                    }
                }
            }

            Dictionary <string, Bitmap> egoSphereVisu = predictedWorld.toImages();

            pictureBoxEgosphereColor.Image = egoSphereVisu["color"];
            pictureBoxEgosphereColor.Refresh();
            pictureBoxEgosphereOrientation.Image = egoSphereVisu["orientation"];
            pictureBoxEgosphereOrientation.Refresh();

            CA3.learningLocked = false;
        }