public static void SaveNetwork(Network network, string path) { Debug.AssertNotNull(path); var info = new NetworkSerializeInfo(); info.GetDataFrom(network); var data = Serializer.Serialize(info); File.WriteAllText(path, data); }
public static Network GetNetwork(string path) { Debug.AssertNotNull(path); var data = File.ReadAllText(path); var network = new Network(); var info = Serializer.Deserialize<NetworkSerializeInfo>(data); info.LoadDataTo(network); return network; }
public void LoadDataTo(Network network) { Debug.AssertNotNull(network); // TODO debug asserts network.TrainingInfo.FromDictionary(StateInfo); for (var l = 0; l < WeightsInfo.Length; l++) { var layer = network.Layers[l]; for (var w = 0; w < WeightsInfo[l].Length; w++) { layer.Weights[w].Value = WeightsInfo[l][w]; } } }
public void GetDataFrom(Network network) { Debug.Assert(network != null); StateInfo = network.TrainingInfo.ToDictionary(); WeightsInfo = new double[network.Layers.Length][]; for (var l = 0; l < WeightsInfo.Length; l++) { var layer = network.Layers[l]; WeightsInfo[l] = new double[layer.Weights.Length]; for (var w = 0; w < WeightsInfo[l].Length; w++) { WeightsInfo[l][w] = layer.Weights[w].Value; } } }
private void MenuNetworkOpenClick(object sender, EventArgs e) { var dialog = new OpenFileDialog {Title = "Выберите файл нейронной сети", Filter = "Файл сети|*.cnn"}; if (dialog.ShowDialog() != DialogResult.OK) return; var networkPath = dialog.FileName; _network = CNNFileManager.GetNetwork(networkPath); Text = "Нейронная сеть - " + dialog.FileName; }
private void MenuNetworkCreateClick(object sender, EventArgs e) { _network = new Network(); Text = "Нейронная сеть - Новая"; }