diff --git a/DeepNeuralNetworkClassifier/MainWindow.cs b/DeepNeuralNetworkClassifier/MainWindow.cs index af9a2a2..d10f5ca 100644 --- a/DeepNeuralNetworkClassifier/MainWindow.cs +++ b/DeepNeuralNetworkClassifier/MainWindow.cs @@ -378,18 +378,15 @@ protected void SaveJson(ref string FileName, string title, Entry entry, string d var ext = JsonSaver.Filter.Name; - FileName = String.Format("{0}.{1}", GetBaseFileName(FileName), ext); - if (!string.IsNullOrEmpty(data)) { - var fullpath = String.Format("{0}/{1}", directory, FileName); - try { - using (var file = new StreamWriter(fullpath, false)) - { - file.Write(data); - } + Utility.Save(directory, GetBaseFileName(FileName), data); + + FileName = String.Format("{0}.{1}", GetBaseFileName(FileName), ext); + + var fullpath = String.Format("{0}/{1}", directory, FileName); FileName = fullpath; @@ -1345,7 +1342,7 @@ protected void OnSaveNetworkButtonClicked(object sender, EventArgs e) protected void OnUseL2Toggled(object sender, EventArgs e) { Options.UseL2 = UseL2.Active; - + if (UseL2.Active) { UseOptimizer.Active = false; diff --git a/DeepNeuralNetworkClassifier/ModelJSON.cs b/DeepNeuralNetworkClassifier/ModelJSON.cs index d0745b0..9f09bde 100644 --- a/DeepNeuralNetworkClassifier/ModelJSON.cs +++ b/DeepNeuralNetworkClassifier/ModelJSON.cs @@ -99,7 +99,7 @@ public static void Save(string BaseDirectory, string Filename, string json) } } - static string ReadString(string BaseDirectory, string Filename) + static string LoadJSON(string BaseDirectory, string Filename) { var json = ""; @@ -126,7 +126,7 @@ static string ReadString(string BaseDirectory, string Filename) public static ManagedDNN LoadDNN(string BaseDirectory, string Filename, ManagedArray normalization) { - var json = ReadString(BaseDirectory, Filename); + var json = LoadJSON(BaseDirectory, Filename); var network = !string.IsNullOrEmpty(json) ? DeserializeDNN(json) : null; @@ -150,10 +150,5 @@ public static ManagedDNN LoadDNN(string BaseDirectory, string Filename, ManagedA return network; } - - public static string LoadJson(string BaseDirectory, string FileName) - { - return ReadString(BaseDirectory, FileName); - } } }