Пример #1
0
    public void GeneticSaveLoad1()
    {
        // ARRANGE
        string            path    = Application.dataPath + "/Test/testWeights3.text";
        List <double[][]> weights = new List <double[][]>();

        double[][] w1 = new double[][] {
            new double[] { 1.0, 3.5 },
            new double[] { 0.1, 2.0 },
            new double[] { 0.4, 2.3 },
            new double[] { 0.6, 2.0 }
        };

        weights.Add(w1);

        // ACT
        SaveWeights.WriteToFile(path, weights);

        GeneticWeights prop = new GeneticWeights();

        prop.layers       = new int[] { 4, 2 };
        prop.lengthLayers = 2;

        List <double[][]> weightsSaved = prop.LoadWeights(path);

        // ASSERT
        Assert.That(weightsSaved, Is.EqualTo(weights));
    }
Пример #2
0
    public void GeneticSaveLoad2()
    {
        // ARRANGE
        string            path    = Application.dataPath + "/Test/testWeights4.text";
        List <double[][]> weights = new List <double[][]>();

        double[][] w1 = new double[][] {
            new double[] { 1.0, 3.0, 5.0, 7.0, 9.67 },
            new double[] { 0.0, 2.0, 4.0, 6.0, 11.0 },
            new double[] { 0.0, 2.89, 4.0, 6.0, 11.0 },
            new double[] { 0.45, 2.0, 4.3, 6.0, 11.65 },
            new double[] { 0.0, 2.0, 4.0, 6.67, 11.0 },
            new double[] { 0.34, 2.0, 4.0, 6.0, 11.65 }
        };

        weights.Add(w1);

        // ACT
        SaveWeights.WriteToFile(path, weights);

        GeneticWeights prop = new GeneticWeights();

        prop.layers       = new int[] { 6, 5 };
        prop.lengthLayers = 2;

        List <double[][]> weightsSaved = prop.LoadWeights(path);

        // ASSERT
        Assert.That(weightsSaved, Is.EqualTo(weights));
    }
    //Load weights from text file
    public void LoadChild()
    {
        string path = Application.dataPath + "/geneticWeights.text";

        Car.SetWeights(saveLoad.LoadWeights(path));
    }