Esempio n. 1
0
        public void UpdateNetwork(SomNetwork network, Bmu bmu, Vector input)
        {
            var radius = network.Radius * SomUtilities.Shrink(network.Time, network.T0);

            foreach (SomNode node in network.Weights)
            {
                if (Distance.Euclidean(bmu.Position, node.Position) < radius)
                {
                    Vector delta = (Vector)(
                        SomUtilities.Shrink(network.Time, network.T0) *
                        SomUtilities.Shrink(Distance.Euclidean(bmu.Position, node.Position), network.L0) *
                        network.LearningRate * (input - node.Weight));
                    node.Weight = (Vector)(node.Weight + delta);
                }
            }
        }
Esempio n. 2
0
        public Bmu BestMatchingUnit(SomNetwork network, Vector input)
        {
            //Inelegant.
            var bmu = new Bmu()
            {
                Distance = int.MaxValue
            };

            foreach (SomNode node in network.Weights)
            {
                if (Distance.Euclidean(node.Weight, input) < bmu.Distance)
                {
                    bmu.Position = node.Position;
                    bmu.Distance = Distance.Euclidean(node.Weight, input);
                }
            }
            return(bmu);
        }