public void Deserialize() { Dictionary <String, NeuronLayer> neuronLayers = null; FileStream fs = new FileStream("NeuronLayers.dat", FileMode.Open); try { BinaryFormatter formatter = new BinaryFormatter(); neuronLayers = (Dictionary <String, NeuronLayer>)formatter.Deserialize(fs); } catch (SerializationException e) { Console.WriteLine("Failed to deserialize. Reason: " + e.Message); throw; } finally { fs.Close(); } inLayer = (NeuronLayer)neuronLayers["In"]; foreach (KeyValuePair <String, NeuronLayer> n in neuronLayers.Where(z => z.Key.Contains("Hidden")).OrderBy(z => z.Key)) { hiddenLayers.Add(n.Value); } outLayer = (NeuronLayer)neuronLayers["Out"]; }
public NeuroNet(int countInNeurons, int countOutNeurons, List <int> countHiddenNeurons, bool bias = false) { _countHiddenNeurons = countHiddenNeurons; _countInNeurons = countInNeurons; _countOutNeurons = countOutNeurons; _bias = bias; inLayer = new NeuronLayer(); hiddenLayers = new List <NeuronLayer>(); outLayer = new NeuronLayer(); }