Ejemplo n.º 1
0
    private void load()
    {
        Debug.Log("Loading from: " + dataDirectory);
        IEnumerable <string> dataFiles = Directory.EnumerateFiles(dataDirectory, "*.json");

        foreach (string file in dataFiles)
        {
            NetSaveData save = JsonUtility.FromJson <NetSaveData>(File.ReadAllText(file));
            addFittestList(new NetCacheEntry(save.name, save.tag, save.fitness, new NeuralNet.FeedForward(save.layerSizes, save.weights)));
        }
    }
Ejemplo n.º 2
0
    private void save()
    {
        foreach (KeyValuePair <string, SortedList <double, NetCacheEntry> > entry in fittestCache)
        {
            if (entry.Value.Count == 0)
            {
                continue;
            }
            NetCacheEntry fittest = entry.Value.First().Value;
            string        type    = String.Join(".", ((NeuralNet.FeedForward)fittest.net).layerSizes.Select(p => p.ToString()).ToArray());

            string filename = fittest.name + ".json";

            // Save it
            NetSaveData save     = new NetSaveData(fittest.name, fittest.tag, (NeuralNet.FeedForward)fittest.net);
            string      savePath = Path.Combine(dataDirectory, filename);
            File.WriteAllText(savePath, JsonUtility.ToJson(save, true));
            Debug.Log("Saved as " + savePath);
        }
    }