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); } }
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"); }