public Convolutional_Network(int inputHeight, int inputWidth) { Input_Layers_List ill = new Input_Layers_List(inputHeight, inputWidth); layersList.Add(ill); layersCount++; }
public void ReadWeightsFromFile(string path) { layersList.Clear(); layersCount = 0; string[] input = System.IO.File.ReadAllLines(@path); int na = input.Count(i => i == "{"); List <string> s = input.ToList(); int p = 1; for (int i = 0; i < na; i++) { if (s[p] == "0") { int inputH = int.Parse(s[p + 1]); int inputW = int.Parse(s[p + 2]); Input_Layers_List inp = new Input_Layers_List(inputH, inputW); LayersList.Add(inp); layersCount++; p = s.IndexOf("{", p + 2); } else { List <List <List <double> > > weights = new List <List <List <double> > >(); int n = s.IndexOf("}", p); var s1 = s.GetRange(p + 1, n - p - 1); int nn = s1.Count(l => l == "<"); string type = s1[0]; int pp = 0; for (int j = 0; j < nn; j++) { List <List <double> > w = new List <List <double> >(); pp = s1.IndexOf("<", pp) + 1; int endIndex = s1.IndexOf(">", pp); for (int str = pp; str < endIndex; str++) { List <double> temp = new List <double>(); string[] splitStr = s1[str].Split(); for (int l = 0; l < splitStr.Length - 1; l++) { temp.Add(double.Parse(splitStr[l])); } w.Add(temp); } weights.Add(w); } if (type == "2") { AddConvolutionalLayer(weights.Count / LayersList.Last().TablesCount, weights[0].Count, weights[0][0].Count); LayersList.Last().SetWeigths(weights); } else { AddPullingLayer(weights[0].Count, weights[0][0].Count); } p = n + 1; } } }