Exemplo n.º 1
0
    public static Brain Import(string path)
    {
        SequentialModel model = null;
        Brain           brain = null;

        if (path.EndsWith(".json"))
        {
            model = new ReaderKerasModel(path).GetSequentialExecutor();
        }
        else if (path.EndsWith(".txt"))
        {
            model = PersistSequentialModel.DeserializeModel(path);
        }

        if (model != null)
        {
            brain = new Brain(model)
            {
                _weights = model.GetWeights()
            }
        }
        ;

        return(brain);
    }
}
Exemplo n.º 2
0
 public void Export(int generation, string path = "./Assets/Exports/")
 {
     Directory.CreateDirectory(path);
     path = $"{path}{DateTime.Now:yyyy-MM-dd-HH_mm-ss-ffffff}-gen_{generation}-score_{Score:F}";
     PersistSequentialModel.SerializeModel(_model, $"{path}-brain.txt");
 }