Ejemplo n.º 1
0
 /// <summary>
 /// Creates an instance of CompetitiveNeuron with specified input and transfer functions 
 /// </summary>
 /// <param name="inputFunction">neuron input function</param>
 /// <param name="transferFunction">neuron ransfer function</param>
 public CompetitiveNeuron(InputFunction inputFunction, TransferFunction transferFunction)
     : base(inputFunction, transferFunction)
 {
     connectionsFromOtherLayers = new List<Connection>();
     connectionsFromThisLayer = new List<Connection>();
     this.AddInputConnection(this, 1);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates an instance of neuron which can delay output 
 /// </summary>
 /// <param name="inputFunction">neuron input function</param>
 /// <param name="transferFunction">neuron transfer function</param>
 public DelayedNeuron(InputFunction inputFunction,
     TransferFunction transferFunction)
     : base(inputFunction, transferFunction)
 {
     outputHistory = new List<Double>(5); // default delay buffer size is 5
     outputHistory.Add(0);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates and returns neuron instance according to the given specification in neuronProperties.
        /// </summary>
        /// <param name="neuronProperties">specification of neuron properties</param>
        /// <returns>returns instance of neuron with specified properties</returns>
        public static Neuron CreateNeuron(NeuronProperties neuronProperties)
        {
            InputFunction inputFunction = null;
            Type inputFunctionClass = neuronProperties.InputFunction;

            if (!inputFunctionClass.Equals(" "))
            {
                inputFunction = CreateInputFunction(inputFunctionClass);
            }
            else
            {
                WeightsFunction weightsFunction = CreateWeightsFunction(neuronProperties.WeightsFunction);
                SummingFunction summingFunction = CreateSummingFunction(neuronProperties.SummingFunction);

                inputFunction = new InputFunction(weightsFunction, summingFunction);
            }

            TransferFunction transferFunction = CreateTransferFunction(neuronProperties.GetTransferFunctionProperties());

            Neuron neuron = null;
            Type neuronClass = neuronProperties.NeuronType;

            // use two param constructor to create neuron
            Type[] paramTypes = {
                typeof(InputFunction),
                typeof(TransferFunction) };

            ConstructorInfo con = neuronClass.GetConstructor(paramTypes);

            if (con != null)
            {
                Object[] paramList = new Object[2];
                paramList[0] = inputFunction;
                paramList[1] = transferFunction;

                object o = con.Invoke(paramList);
                neuron = (Neuron)o;
            }

            if (neuron == null)
            {
                neuron = (Neuron)Activator.CreateInstance(neuronClass);
            }

            if (neuronProperties.HasProperty("thresh"))
            {
                ((ThresholdNeuron)neuron).Thresh = ((Double)neuronProperties.GetProperty("thresh"));
            }
            else if (neuronProperties.HasProperty("bias"))
            {
                ((InputOutputNeuron)neuron).Bias = ((Double)neuronProperties.GetProperty("bias"));
            }

            return neuron;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a neuron with threshold behaviour, and with the specified input
 /// and transfer functions. 
 /// </summary>
 /// <param name="inputFunction">input function for this neuron</param>
 /// <param name="transferFunction">transfer function for this neuron</param>
 public ThresholdNeuron(InputFunction inputFunction, TransferFunction transferFunction)
 {
     this.InputFunction = inputFunction;
     this.TransferFunction = transferFunction;
     this.Thresh = ThreadSafeRandom.NextDouble();
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates an instance of neuron for Hopfield network with specified input
 /// and transfer functions 
 /// </summary>
 /// <param name="inFunc">neuron input function</param>
 /// <param name="transFunc">neuron transfer function</param>
 public InputOutputNeuron(InputFunction inFunc, TransferFunction transFunc)
     : base(inFunc, transFunc)
 {
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Creates an instance of Neuron with the specified input and transfer functions. 
 /// </summary>
 /// <param name="inputFunction">input function for this neuron</param>
 /// <param name="transferFunction">transfer function for this neuron</param>
 public Neuron(InputFunction inputFunction, TransferFunction transferFunction)
 {
     this.InputFunction = inputFunction;
     this.TransferFunction = transferFunction;
 }