Esempio n. 1
0
        /// <summary>
        /// Returns the absolute values
        /// </summary>
        /// <param name="a">A.</param>
        /// <returns>The result of the operator.</returns>
        public static IWeights Absolute(this IWeights a)
        {
            var weights = new WeightVector(a);

            for (var i = 0; i < a.Length; ++i)
            {
                weights[i] = Math.Abs(weights[i]);
            }
            return(weights);
        }
Esempio n. 2
0
        /// <summary>
        /// Calculates the new weights.
        /// </summary>
        /// <param name="iteration">The iteration.</param>
        /// <param name="trainingVector">The training vector.</param>
        /// <param name="currentWeights">The current weights.</param>
        /// <param name="distance">The distance.</param>
        /// <returns>IWeights.</returns>
        public IWeights CalculateNewWeights(int iteration, IWeights trainingVector, IWeights currentWeights, double distance)
        {
            var radius  = _radiusFunction.CalculateRadius(iteration);
            var h       = _neighboorFunction.CalculateFactor(distance, radius);
            var epsilon = _learningRate.CalculateLearningRate(iteration);
            var factor  = h * epsilon;

            // Ritter et al. (1991)

            // calculate V(t)-W(t)
            var delta = trainingVector.Subtract(currentWeights);

            // calculate W(t) + N(t)*L(t) * (V(t)-W(t))
            var weights = new WeightVector(currentWeights);

            return(weights.AddScaledInPlace(delta, factor));
        }
Esempio n. 3
0
        /// <summary>
        /// Creates the random.
        /// </summary>
        /// <param name="generator">The generator.</param>
        /// <returns>INeuron.</returns>
        public INeuron CreateRandom(IRandomNumber generator)
        {
            var dimensions = _dimensions;

            // create weights
            var weigths = new WeightVector(dimensions);

            for (int i = 0; i < dimensions; ++i)
            {
                weigths[i] = generator.GetDouble(0, 1);
            }

            // create neuron
            var neuron = new Kohonen.Neuron.Neuron(weigths);

            return(neuron);
        }
Esempio n. 4
0
        /// <summary>
        /// Implements the -.
        /// </summary>
        /// <param name="a">A.</param>
        /// <param name="b">The b.</param>
        /// <returns>The result of the operator.</returns>
        public static IWeights Subtract(this IWeights a, IWeights b)
        {
            var weights = new WeightVector(a);

            return(SubtractInPlace(weights, b));
        }
Esempio n. 5
0
        /// <summary>
        /// Implements the +.
        /// </summary>
        /// <param name="a">A.</param>
        /// <param name="b">The b.</param>
        /// <returns>The result of the operator.</returns>
        public static IWeights AddScaled(this IWeights a, IWeights b, double s)
        {
            var weights = new WeightVector(a);

            return(AddScaledInPlace(weights, b, s));
        }
Esempio n. 6
0
        public static IWeights Add([NotNull] this IWeights a, [NotNull] IWeights b)
        {
            var weights = new WeightVector(a);

            return(AddInPlace(weights, b));
        }
Esempio n. 7
0
        /// <summary>
        /// Implements the *.
        /// </summary>
        /// <param name="a">A.</param>
        /// <param name="s">The s.</param>
        /// <returns>The result of the operator.</returns>
        public static IWeights Scale(IWeights a, double s)
        {
            var weights = new WeightVector(a);

            return(ScaleInPlace(weights, s));
        }