SaneeshTG / accord

Automatically exported from code.google.com/p/accord
0 stars 0 forks source link

MultivariateNormalDistribution used with HMMs - "Weights do not sum to one" #78

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use a large number of samples (>5500)
2. Train the classiifer with this large number of sample
3.

What is the expected output? What do you see instead?
I expect the classifier to be trained.
I obtain an exception "Weights do not sum to one."

What version of the product are you using? On what operating system?
2. 2.10.0.0

Please provide any additional information below.

During the weighted mean computation, there is a test in IF(DEBUG) that yields 
an exception. 

In MultivaraiteDistribution.cs

--> thw two last lines have been commented, otherwise with large number of 
samples, probably due to rounding errors, the sum is > 1e-10 (the error 
arrrives with more than 5500 samples/weights)
#if DEBUG
                double sum = 0;
                for (int i = 0; i < weights.Length; i++)
                {
                    if (Double.IsNaN(weights[i]) || Double.IsInfinity(weights[i]))
                        throw new ArgumentException("Invalid numbers in the weight vector.", "weights");
                    sum += weights[i];
                }

                //if (Math.Abs(sum - 1.0) > 1e-10)
                  //  throw new ArgumentException("Weights do not sum to one.", "weights");
#endif

Original issue reported on code.google.com by simon.ru...@gmail.com on 15 Oct 2013 at 10:30

GoogleCodeExporter commented 9 years ago
Called from the following code:

 var myTeacher = new HiddenMarkovClassifierLearning<MultivariateNormalDistribution>(hmmc, i =>
                new BaumWelchLearning<MultivariateNormalDistribution>(hmmc.Models[i])
                {
                    Iterations = iterations,
                    Tolerance = limit,
                    //FittingOptions = new NormalOptions() { Regularization = 1e-5, Diagonal = true }
                    FittingOptions = new NormalOptions() { Regularization = 1e-5 }
                }
            );

            myTeacher.Run(sequences, labels);

Original comment by simon.ru...@gmail.com on 15 Oct 2013 at 10:31

GoogleCodeExporter commented 9 years ago
Thanks for reporting the bug. The DEBUG flag should not have been active during 
the Release compilation, unless I packed up the wrong assemblies in the latest 
release. Thanks for letting me know, I will investigate!

Original comment by cesarso...@gmail.com on 18 Oct 2013 at 7:14

GoogleCodeExporter commented 9 years ago
Should have been fixed in the 2.11 release.

Original comment by cesarso...@gmail.com on 27 Oct 2013 at 4:51