public NeuralLayer(String initiateFileName) { string directory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); string filePath = Path.Combine(directory, initiateFileName); if (!File.Exists(filePath)) { using (StreamWriter writetext = new StreamWriter(initiateFileName)) { for (int i = 0; i < neuronNum; i++) { mainLayer[i] = new CasificationNeuron(); writetext.WriteLine(mainLayer[i].generateWeightView()); } } } else { using (StreamReader readtext = new StreamReader(initiateFileName)) { for (int i = 0; i < neuronNum; i++) { string [] readMeText = readtext.ReadLine().Split(','); double[] sendToNeuron = new Double [Worker.parameters]; for (int j = 0; j < Worker.parameters; j++) { sendToNeuron[j] = Double.Parse(readMeText[j]); } mainLayer[i] = new CasificationNeuron(sendToNeuron); } } } }
protected override void saveProgres() { using (StreamWriter writetext = new StreamWriter("supervisedNeuralBrain.txt")) { for (int i = 0; i < neuronNum; i++) { mainLayer[i] = new CasificationNeuron(); writetext.WriteLine(mainLayer[i].generateWeightView()); } } }