public Neuron(BinaryReader aReader, SerializationContext <Neuron> aContext) { byte marker = aReader.ReadByte(); if (marker != 0x3) { throw new System.Exception("Binarystream: expected neuron (0x3) got " + marker); } uint id = aReader.ReadUInt32(); type = (ENeuronType)aReader.ReadByte(); activationType = (EActivationType)aReader.ReadByte(); SigmoidBase = aReader.ReadSingle(); int count = aReader.ReadInt32(); if (count >= 0) { inputs = new NeuronLink[count]; } for (int i = 0; i < count; i++) { int index = i; aContext.GetObject(aReader.ReadUInt32(), (n) => inputs[index].neuron = n); inputs[i].weight = aReader.ReadSingle(); } aContext.RegisterObject(id, this); }
public NeuronLayer(ENeuronType aType, int aNeuronCount) { type = aType; neurons = new List <Neuron>(aNeuronCount); for (int i = 0; i < aNeuronCount; i++) { neurons.Add(new Neuron(aType)); } }
private void NeuronInit(int inovationNb, ENeuronType type) { InnerValue = 0; InnovationNb = inovationNb; Type = type; InGenes = new List <Gene>(); OutGenes = new List <Gene>(); }
public NeuronLayer(XmlNode aNode, SerializationContext <Neuron> aContext) { if (aNode.Name != "Layer") { throw new System.Exception("Expected element 'Layer' but got '" + aNode.Name + "'"); } type = (ENeuronType)System.Enum.Parse(typeof(ENeuronType), aNode.Attributes["type"].Value); int count = aNode.ChildNodes.Count; neurons = new List <Neuron>(count); for (int i = 0; i < count; i++) { neurons.Add(new Neuron(aNode.ChildNodes[i], aContext)); } }
public NeuronLayer(BinaryReader aReader, SerializationContext <Neuron> aContext) { byte marker = aReader.ReadByte(); if (marker != 0x2) { throw new System.Exception("Binarystream: expected layer (0x2) got " + marker); } type = (ENeuronType)aReader.ReadByte(); int count = aReader.ReadInt32(); neurons = new List <Neuron>(count); for (int i = 0; i < count; i++) { neurons.Add(new Neuron(aReader, aContext)); } }
public Neuron(XmlNode aNode, SerializationContext <Neuron> aContext) { if (aNode.Name != "Neuron") { throw new System.Exception("Expected element 'Neuron' but got '" + aNode.Name + "'"); } var id = uint.Parse(aNode.Attributes["id"].Value); type = (ENeuronType)System.Enum.Parse(typeof(ENeuronType), aNode.Attributes["type"].Value); activationType = (EActivationType)System.Enum.Parse(typeof(EActivationType), aNode.Attributes["activationType"].Value); SigmoidBase = float.Parse(aNode.Attributes["SigmoidBase"].Value); inputs = new NeuronLink[aNode.ChildNodes.Count]; for (int i = 0; i < inputs.Length; i++) { int index = i; var link = aNode.ChildNodes.Item(i); inputs[i].weight = float.Parse(link.Attributes["weight"].Value); var neuronId = uint.Parse(link.Attributes["neuron"].Value); aContext.GetObject(neuronId, (n) => inputs[index].neuron = n); } aContext.RegisterObject(id, this); }
public Neuron(ENeuronType aType) { type = aType; }
public PackedNeuron(Neuron neuron) { innovationNb = neuron.InnovationNb; type = neuron.Type; }
public Neuron(int inovationNb, ENeuronType type = ENeuronType.Hidden) { NeuronInit(inovationNb, type); }