Ejemplo n.º 1
0
    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());
    }
Ejemplo n.º 2
0
    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;
    }
Ejemplo n.º 3
0
    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);
    }