/// <summary> /// Creates a new nuron on a given network, with a given activation /// function and level depth. An index is required to be able to /// refrence the nuron from outside the network. /// </summary> /// <param name="network">Network on wich to create the nuron</param> /// <param name="func">Activation funciton of the nuron</param> /// <param name="index">Index of the nuron</param> /// <param name="level">Level of the nuron</param> internal Nuron(NetworkAuto network, ActFunc func, int index, int level) { this.network = network; this.func = func; this.index = index; this.level = level; this.value = 0.0; this.vprev = 0.0; }
internal Nuron(NetworkAuto network, Nuron other) { this.network = network; this.func = other.func; this.index = other.index; this.level = other.level; this.value = 0.0; this.vprev = 0.0; }
///// <summary> ///// Obtains the axon that connects to this nuron from another given ///// nuron. Note that the order of the nurons is important. It returns ///// null if no sutch connection exists. ///// </summary> ///// <param name="index">Index of another nuron</param> ///// <returns>The axon conecting the nurons</returns> //public Axon GetAxon(int index) //{ // //checkes that we have not been disposed // if (network == null) return null; // foreach (int aid in inputs) // { // //checks each axon for a match // if (aid == index) return network.GetAxon(index); // } // //we faild to find the axon // return null; //} ///// <summary> ///// Obtains the axon that connects to this nuron from another given ///// nuron. Note that the order of the nurons is important. It returns ///// null if no sutch connection exists. ///// </summary> ///// <param name="other">Another nuron</param> ///// <returns>The axon conecting the nurons</returns> //public Axon GetAxon(Nuron other) //{ // //checks that both nurons belong to the same network // if (network != other.network) return null; // //obtains the axon by the other's index // return GetAxon(other.Index); //} ////public Axon AddAxon(Nuron input, double weight) ////{ //// if (input.Level > this.Level) //// { //// //swaps the nurons if the level is swaped //// return input.AddAxon(this, weight); //// } //// //enshures that the nurons are on diffrent levels //// if (input.Level == this.Level) throw new //// InvalidOperationException(); //// //enshures that the nurons belong to the same network //// if (input.network != this.network) throw new //// InvalidOperationException(); //// //calls upon the internal method //// return AddAxonInit(input, weight); ////} #endregion //////////////////////////////////////////////////////////////////// #region Internal Methods... ///// <summary> ///// Connects the given input nuron to the current nuron with the ///// given weight. Note that it dose not check the topology of the ///// network before adding the axon, so care must be taken to avoid ///// redundent connections. If a connection already exists between ///// the two nurons, it returns that axon instead. ///// </summary> ///// <param name="input">Nuron to conect</param> ///// <param name="weight">Weight of the connection</param> ///// <returns>The axon between the nurons</returns> //internal Axon AddAxonInit(Nuron input, double weight) //{ // //makes shure our parent network hasn't been disposed // if (network == null) throw new InvalidOperationException(); // //sees if we alreay contain a link to the input // Axon ax = GetAxon(input.Index); // if (ax == null) // { // //obtains an index to the sorce and target // int source = this.Index; // int target = input.Index; // //creates the axon and adds it to our list // ax = new Axon(source, target, weight); // inputs.Add(ax); // } // else // { // //sets the axons weight to our new weight // ax.Weight = weight; // } // return ax; //} /// <summary> /// Clears all the data contained in this node. It is nessary to /// call this when disposing of the parent network in order to /// avoid cyclical refrences and potential memory leaks. /// </summary> internal void ClearData() { //deletes the network to avoid cyclic refrences this.network = null; }