예제 #1
0
파일: Brain.cs 프로젝트: Hugu3s/sonaris
    private int outputLength = 0;    // Replace data[0].output.length

    // Use this for initialization
    void Start()
    {
        InputData  trainingInput  = new InputData();
        OutputData trainingOutput = new OutputData();

        string[] inputKeys  = { "rouge", "vert", "bleu" };
        string[] outputKeys = { "rouge", "vert", "bleu", "jaune", "cyan", "rose", "blanc" };
        trainingInput.Add(inputKeys, new double[] { 255, 0, 0 });
        trainingOutput.Add(outputKeys, new double[] { 1, 0, 0, 0, 0, 0, 0.3 });
        trainingInput.Add(inputKeys, new double[] { 0, 255, 0 });
        trainingOutput.Add(outputKeys, new double[] { 0, 1, 0, 0, 0, 0, 0.3 });
        trainingInput.Add(inputKeys, new double[] { 0, 0, 255 });
        trainingOutput.Add(outputKeys, new double[] { 0, 0, 1, 0, 0, 0, 0.3 });
        trainingInput.Add(inputKeys, new double[] { 255, 255, 0 });
        trainingOutput.Add(outputKeys, new double[] { 0, 0, 0, 1, 0, 0, 0.6 });
        trainingInput.Add(inputKeys, new double[] { 0, 255, 255 });
        trainingOutput.Add(outputKeys, new double[] { 0, 0, 0, 0, 1, 0, 0.6 });
        trainingInput.Add(inputKeys, new double[] { 255, 0, 255 });
        trainingOutput.Add(outputKeys, new double[] { 0, 0, 0, 0, 0, 1, 0.6 });
        trainingInput.Add(inputKeys, new double[] { 255, 255, 255 });
        trainingOutput.Add(outputKeys, new double[] { 0, 0, 0, 0, 0, 0, 1 });
        trainingInput.Add(inputKeys, new double[] { 0, 0, 0 });
        trainingOutput.Add(outputKeys, new double[] { 0, 0, 0, 0, 0, 0, 0 });
        trainingInput.Add(inputKeys, new double[] { 128, 128, 128 });
        trainingOutput.Add(outputKeys, new double[] { 0, 0, 0, 0, 0, 0, 0.5 });
        trainingInput.Add(inputKeys, new double[] { 128, 0, 128 });
        trainingOutput.Add(outputKeys, new double[] { 0, 0, 0, 0, 0, 0.5, 0.5 });


        var stats = Train(trainingInput, trainingOutput);
        var input = new AssociativeArray <double>();

        input.Add(inputKeys, new double[] { 240, 2, 20 });
        Debug.Log(Run(input).ToString());
    }
예제 #2
0
파일: Data.cs 프로젝트: Hugu3s/sonaris
    public void Add(string[] keys, double[] values)
    {
        AssociativeArray <double> aa = new AssociativeArray <double>();

        for (int i = 0; i < keys.Length; ++i)
        {
            aa.Add(keys[i], values[i]);
        }
        data.Add(aa);
        length = data.Count;
    }
예제 #3
0
파일: Brain.cs 프로젝트: Hugu3s/sonaris
    public AssociativeArray <double> Train(InputData input, OutputData output)
    {
        AssociativeArray <double> status = new AssociativeArray <double>();

        CreateInputLookup(input);
        CreateOutputLookup(output);
        Initialize(input, output);
        DateTime endTime = DateTime.Now;

        endTime.AddDays(timeout);
        status.Add("error", 1);
        status.Add("iterations", 0);

        bool goOn = true;

        while (goOn)
        {
            goOn = TrainingTick(input, output, status, endTime);
        }
        return(status);
    }