Пример #1
0
        private void addModelToSenonePool(Pool pool, int[] array, float num, float num2)
        {
            if (!ModelInitializerLoader.assertionsDisabled && pool == null)
            {
                throw new AssertionError();
            }
            int gauPerState = this.mixtureWeights.getGauPerState();

            if (!ModelInitializerLoader.assertionsDisabled && gauPerState <= 0)
            {
                throw new AssertionError();
            }
            int num3 = array.Length;

            for (int i = 0; i < num3; i++)
            {
                int num4 = array[i];
                MixtureComponent[] array2 = new MixtureComponent[gauPerState];
                for (int j = 0; j < gauPerState; j++)
                {
                    int id = num4 * gauPerState + j;
                    MixtureComponent[] array3 = array2;
                    int num5 = j;
                    array3[num5] = new MixtureComponent((float[])this.meansPool.get(id), (float[][])this.meanTransformationMatrixPool.get(0), (float[])this.meanTransformationVectorPool.get(0), (float[])this.variancePool.get(id), (float[][])this.varianceTransformationMatrixPool.get(0), (float[])this.varianceTransformationVectorPool.get(0), num, num2);
                }
                GaussianMixture o = new GaussianMixture(this.mixtureWeights, array2, num4);
                pool.put(num4, o);
            }
        }
        public void MixtureComponent_UnivariateMeanTransformation()
        {
            const float mean = 20;
            const float var  = 0.001f;

            var gaussian = new MixtureComponent(new[] { mean }, new[] { new float[] { 2 } }, new float[] { 5 }, new[] { var }, null, null);

            Assert.IsTrue(LogMath.GetLogMath().LogToLinear(gaussian.GetScore(new[] { 2 * mean + 5 })) > 10);
        }
        public void MixtureComponent_Clone()
        {
            var gaussian = new MixtureComponent(new float[] { 2 }, new[] { new float[] { 3 } }, new float[] { 4 }, new float[] { 5 }, new[] { new float[] { 6 } }, new float[] { 7 });

            var clonedGaussian = gaussian.Clone();

            Assert.IsTrue(!clonedGaussian.Equals(gaussian));

            Assert.IsTrue(gaussian.Mean != clonedGaussian.Mean);

            Assert.IsTrue(gaussian.Variance != clonedGaussian.Variance);

            Assert.IsTrue(gaussian.GetScore(new float[] { 2 }) == clonedGaussian.GetScore(new float[] { 2 }));
        }
Пример #4
0
 private void recomputeMixtureComponents()
 {
     for (int i = 0; i < this.senonePool.size(); i++)
     {
         GaussianMixture    gaussianMixture   = (GaussianMixture)this.senonePool.get(i);
         MixtureComponent[] mixtureComponents = gaussianMixture.getMixtureComponents();
         MixtureComponent[] array             = mixtureComponents;
         int num = array.Length;
         for (int j = 0; j < num; j++)
         {
             MixtureComponent mixtureComponent = array[j];
             mixtureComponent.precomputeDistance();
         }
     }
 }
        public void MixtureComponent_UnivariateDensity()
        {
            const float minX       = 10;
            const float maxX       = 30;
            const float resolution = 0.1f;

            const float mean = 20;
            const float var  = 3;

            var gaussian = new MixtureComponent(new[] { mean }, new[] { var });

            for (var curX = minX; curX <= maxX; curX += resolution)
            {
                var gauLogScore = gaussian.GetScore(new FloatData(new[] { curX }, 16000, 0));

                var manualScore = (1 / Math.Sqrt(var * 2 * Math.PI)) * Math.Exp((-0.5 / var) * (curX - mean) * (curX - mean));
                var gauScore    = LogMath.GetLogMath().LogToLinear((float)gauLogScore);

                Assert.AreEqual(manualScore, gauScore, 1E-5);
            }
        }