private void loadButton_Clicked(object sender, EventArgs e) { if (openFileDialog2.ShowDialog() == DialogResult.OK) { _network = DeepBeliefNetwork.Load(openFileDialog2.FileName); } }
private void LoadNetworks() { for (var i = 0; i <= Constants.MaxEmptiesCount; i++) { var networkFile = Path.Combine(networkPath, "deeplearning-19.net"); if (!File.Exists(networkFile)) { continue; } networks[i] = DeepBeliefNetwork.Load(networkFile); } }
//初始化載入DBN網路狀態 public static bool Initialization(string Path) { try { DBNetwork = DeepBeliefNetwork.Load(Path); Console.WriteLine("建置完成"); } catch (Exception ex) { Debug.WriteLine(ex.ToString()); return(false); } return(true); }
public Model LoadModel(string filePath) { using (var tempDirectory = new TemporaryDirectory()) { ZipFile.ExtractToDirectory(filePath, tempDirectory.Path); return(new Model() { Network = DeepBeliefNetwork.Load(GetNetworkPath(tempDirectory.Path)), ClassifierConfiguration = Serializer.Load <ClassifierConfiguration>( GetClassifierConfigurationPath(tempDirectory.Path)), DataProviderConfiguration = Serializer.Load <DataProviderConfiguration>( GetDataProviderConfigurationPath(tempDirectory.Path)) }); } }
public double[][] Compute(double[][] i) { if (n == null) { n = DeepBeliefNetwork.Load(p); } List <double[]> d = new List <double[]>(); for (int j = 0; j < i.Length; j++) { d.Add(n.Compute(i[j])); } return(d.ToArray()); }
public void Train(double[][] i, double[][] o = null, int outputLength = 10, int hiddenLayer = -1) { if (n == null) { if (File.Exists(p)) { n = DeepBeliefNetwork.Load(p); } else { outputLength = (o == null) ? outputLength : o[0].Length; hiddenLayer = (hiddenLayer == -1) ? (int)Math.Log(i[0].Length, outputLength) : hiddenLayer; List <int> layers = new List <int>(); for (int j = 0; j < hiddenLayer; j++) { layers.Add(i[0].Length); } layers.Add(outputLength); n = new DeepBeliefNetwork(new BernoulliFunction(), i[0].Length, layers.ToArray()); new GaussianWeights(n).Randomize(); } } dynamic t; if (o == null) { t = new DeepBeliefNetworkLearning(n) { Algorithm = (h, v, j) => new ContrastiveDivergenceLearning(h, v), LayerIndex = n.Machines.Count - 1, }; while (true) { e = t.RunEpoch(t.GetLayerInput(i)); } } else { t = new DeepNeuralNetworkLearning(n) { Algorithm = (ann, j) => new ParallelResilientBackpropagationLearning(ann), LayerIndex = n.Machines.Count - 1, }; while (true) { e = t.RunEpoch(t.GetLayerInput(i), o); } } }
private static void Test(double[][] inputs, double[][] outputs) { var network = DeepBeliefNetwork.Load(@"deeplearning-results\deeplearning-countbits.net"); // Test the resulting accuracy. int correct = 0; for (int i = 0; i < inputs.Length; i++) { double[] outputValues = network.Compute(inputs[i]); if (Compare(outputValues, outputs[i])) { correct++; } } Console.WriteLine("Correct " + correct + "/" + inputs.Length + ", " + Math.Round(((double)correct / (double)inputs.Length * 100), 2) + "%"); }
private static void VaildateDeepLearningEngine(int empties) { var dataPath = Path.Combine(Environment.CurrentDirectory, $@"knowledge\{empties}\"); var items = ConvertData(LoadItems(dataPath)); var count = items.Length; var inputs = items.Select(x => x.Inputs).ToArray(); var outputs = items.Select(x => x.Outputs).ToArray(); Console.WriteLine($"[{empties}] test {inputs.Length} items--------------------------------"); Console.WriteLine($"DeepBeliefNetwork--------------------------------"); var networkFile = Path.Combine(networkPath, $@"deeplearning-{empties}.net"); var network = DeepBeliefNetwork.Load(networkFile); Test(networkFile, inputs, outputs); Console.WriteLine($"DeepLearningEngine--------------------------------"); int correct = 0; var error = 0.0; for (int i = 0; i < inputs.Length; i++) { var outputValues = DeepLearningEngineSearch(items[i].Board); if (Compare(outputValues, outputs[i])) { correct++; } error += Error(outputValues, outputs[i]); if ((i + 1) % 10 == 0) { Console.WriteLine("Correct " + correct + "/" + (i + 1) + ", " + Math.Round(((double)correct / (double)(i + 1) * 100), 2) + "%"); } } Console.WriteLine("Correct " + correct + "/" + inputs.Length + ", " + Math.Round(((double)correct / (double)inputs.Length * 100), 2) + "%"); error = Math.Sqrt(error / inputs.Length); Console.WriteLine($"Error: {error }"); }
private static void Test(string networkFile, double[][] inputs, double[][] outputs) { Console.WriteLine($"test {inputs.Length} items--------------------------------"); var network = DeepBeliefNetwork.Load(networkFile); // Test the resulting accuracy. int correct = 0; var error = 0.0; for (int i = 0; i < inputs.Length; i++) { double[] outputValues = network.Compute(inputs[i]); if (Compare(outputValues, outputs[i])) { correct++; } error += Error(outputValues, outputs[i]); } Console.WriteLine("Correct " + correct + "/" + inputs.Length + ", " + Math.Round(((double)correct / (double)inputs.Length * 100), 2) + "%"); error = Math.Sqrt(error / inputs.Length); Console.WriteLine($"Error: {error }"); }
public void Load(string filename) { Network = DeepBeliefNetwork.Load(filename); }
public void LoadNetworkFromFile(string filePath) { network = DeepBeliefNetwork.Load(filePath); supervisedTeacher = GetSupervisedTeacherForNetwork(network); unsuperVisedTeacher = GetUnsupervisedTeacherForNetwork(network); }
public void LoadNetwork(String path) { network = DeepBeliefNetwork.Load(path); }
public void LoadNetwork(string name) { _network = DeepBeliefNetwork.Load(name); }