/// <summary> /// Constructs a new layer, and sets some initial values /// </summary> /// <param name="OwnedDNAToSet">DNA that dictates the properties of the layer</param> /// <param name="DestinationLayerToSet">Initial Destination layer.</param> /// <param name="SourceLayerToSet">Initial source layer</param> public Layer(Brain OwnedBrainToSet, DNA OwnedDNAToSet, Layer DestinationLayerToSet, Layer SourceLayerToSet, bool UseByteResolution) { this.ByteResolution =UseByteResolution; this.OwnedBrain = OwnedBrainToSet; this.SourceLayer = SourceLayerToSet; this.DestinationLayer = DestinationLayerToSet; this.OwnedDNA = OwnedDNAToSet; this.Uid = this.OwnedBrain.GetNextLayerId(); }
/// <summary> /// Creates a new InputLayer and initilizes some values /// </summary> /// <param name="OwnedDNAToSet">DNA that dictates the attributes of the layer</param> /// <param name="DestinationLayerToSet">Destination layer to connect this layer to</param> public InputLayer(Brain OwnedBrainToSet, DNA OwnedDNAToSet, Layer DestinationLayerToSet, bool UseByteResolution) : base(OwnedBrainToSet, OwnedDNAToSet, DestinationLayerToSet, null, UseByteResolution) { this.SourceLayer = null; }
/// <summary> /// Constructs a new input neuron and sets some inital value /// </summary> /// <param name="OwningLayerToSet">Layer that owns the new neuron</param> /// <param name="OwnedDNAToSet">DNA that sets the neurons properties</param> public InputNeuron(Layer OwningLayerToSet, bool IsByteResolution, double InitialBiasWeight, uint UidToSet) : base(OwningLayerToSet, IsByteResolution, InitialBiasWeight, UidToSet) { if((OwningLayerToSet is InputLayer) != true) throw new Exception("Input neuron can only belong to an InputLayer"); }
/// <summary> /// Constructs a new input neuron and sets some inital value /// </summary> /// <param name="OwningLayerToSet">Layer that owns the new neuron</param> /// <param name="OwnedDNAToSet">DNA that sets the neurons properties</param> public InputNeuron(Layer OwningLayerToSet, DNA OwnedDNAToSet, bool IsByteResolution) : base(OwningLayerToSet, OwnedDNAToSet, IsByteResolution) { if((OwningLayerToSet is InputLayer) != true) throw new Exception("Input neuron can only belong to an InputLayer"); }
/// <summary> /// Constructs a new OutputNeuron and sets some intial data. /// </summary> /// <param name="OwningLayerToSet">Layer that owns the neuron</param> /// <param name="OwnedDNAToSet">DNA that dictates the neurons properties</param> public OutputNeuron(Layer OwningLayerToSet, DNA OwnedDNAToSet, bool IsByteResolution) : base(OwningLayerToSet, OwnedDNAToSet, IsByteResolution) { if((OwningLayerToSet is OutputLayer) != true) throw new Exception("OutputNeurons can only belong to OutputLayers"); }
/// <summary> /// This method should not be called in an OutputLayer. Throws an error if called. /// </summary> /// <param name="LayerToConnectTo">Not used</param> public override void ConnectAllToLayer(Layer LayerToConnectTo) { throw new Exception("An output layer cannot connect to other layers"); }
/// <summary> /// Connect all the neurons in the layer to the neurons int he specified layer /// </summary> /// <param name="LayerToConnectTo">Layer to connect to</param> public virtual void ConnectAllToLayer(Layer LayerToConnectTo) { if( LayerToConnectTo is InputLayer ) throw new Exception("Cannot connect to an input layer"); IEnumerator FromNeuronsEnum = this.NeuronsOwned.GetEnumerator(); while( FromNeuronsEnum.MoveNext() ) { if( FromNeuronsEnum.Current is Neuron ) { Neuron FromNeuron = FromNeuronsEnum.Current as Neuron; IEnumerator ToNeuronsEnum = LayerToConnectTo.NeuronsOwned.GetEnumerator(); while( ToNeuronsEnum.MoveNext() ) { if(ToNeuronsEnum.Current is Neuron) { Neuron ToNeuron = ToNeuronsEnum.Current as Neuron; FromNeuron.ConnectToNeuron(ToNeuron); } else throw new Exception("Layer owns non neurons classes"); } } else throw new Exception("NeuronsOwned can only contain neurons"); } }
public void ConnectAllToForwardLayers(Layer LastLayerToConnectTo) { Layer CurrentToLayer = this.DestinationLayer; while((CurrentToLayer != null)&&(CurrentToLayer != LastLayerToConnectTo)) { this.ConnectAllToLayer(CurrentToLayer); CurrentToLayer = CurrentToLayer.DestinationLayer; } if( LastLayerToConnectTo != null ) this.ConnectAllToLayer(LastLayerToConnectTo); }