Ejemplo n.º 1
0
        protected internal void accumulate(int num, TrainerScore[] array, TrainerScore[] array2)
        {
            TrainerScore trainerScore = array[num];

            this.currentLogLikelihood = 0f;
            this.logLikelihood       -= array[0].getScalingFactor();
            SenoneHMMState senoneHMMState = (SenoneHMMState)trainerScore.getState();

            if (senoneHMMState == null)
            {
                int num2 = trainerScore.getSenoneID();
                if (num2 == -1)
                {
                    this.accumulateMean(num2, array[num]);
                    this.accumulateVariance(num2, array[num]);
                    this.accumulateMixture(num2, array[num]);
                    this.accumulateTransition(num2, num, array, array2);
                }
            }
            else if (senoneHMMState.isEmitting())
            {
                int num2 = this.senonePool.indexOf(senoneHMMState.getSenone());
                this.accumulateMixture(num2, array[num]);
                this.accumulateTransition(num2, num, array, array2);
            }
        }
Ejemplo n.º 2
0
        private float calculateScores(int i)
        {
            SenoneHMMState senoneHMMState = (SenoneHMMState)this.graph.getNode(i).getObject();
            float          result;

            if (senoneHMMState != null && senoneHMMState.isEmitting())
            {
                this.componentScores = senoneHMMState.calculateComponentScore(this.curFeature);
                result = senoneHMMState.getScore(this.curFeature);
                if (!BaumWelchLearner.assertionsDisabled && this.componentScores.Length != 1)
                {
                    throw new AssertionError();
                }
            }
            else
            {
                this.componentScores = null;
                result = 0f;
            }
            return(result);
        }
Ejemplo n.º 3
0
        private void forwardPass(TrainerScore[] array)
        {
            for (int i = 0; i < this.graph.size(); i++)
            {
                this.outputProbs[i] = this.calculateScores(i);
                array[i]            = new TrainerScore(this.curFeature, this.outputProbs[i], (HMMState)this.graph.getNode(i).getObject(), this.componentScores);
                array[i].setAlpha(this.probCurrentFrame[i]);
            }
            float[] array2 = this.probCurrentFrame;
            this.probCurrentFrame = new float[this.graph.size()];
            int j;

            for (j = 0; j < this.graph.size(); j++)
            {
                Node node = this.graph.getNode(j);
                if (node.isType("STATE"))
                {
                    SenoneHMMState senoneHMMState = (SenoneHMMState)node.getObject();
                    SenoneHMM      senoneHMM      = (SenoneHMM)senoneHMMState.getHMM();
                    if (senoneHMMState.isEmitting())
                    {
                        this.probCurrentFrame[j] = float.MinValue;
                        node.startIncomingEdgeIterator();
                        while (node.hasMoreIncomingEdges())
                        {
                            Node     source   = node.nextIncomingEdge().getSource();
                            int      num      = this.graph.indexOf(source);
                            HMMState hmmstate = (HMMState)source.getObject();
                            float    num2;
                            if (hmmstate != null)
                            {
                                if (!BaumWelchLearner.assertionsDisabled && hmmstate.isEmitting() && hmmstate.getHMM() != senoneHMM)
                                {
                                    throw new AssertionError();
                                }
                                if (!hmmstate.isEmitting())
                                {
                                    num2 = 0f;
                                }
                                else
                                {
                                    num2 = senoneHMM.getTransitionProbability(hmmstate.getState(), senoneHMMState.getState());
                                }
                            }
                            else
                            {
                                num2 = 0f;
                            }
                            this.probCurrentFrame[j] = this.logMath.addAsLinear(this.probCurrentFrame[j], array2[num] + num2);
                        }
                        float[] array3 = this.probCurrentFrame;
                        int     num3   = j;
                        float[] array4 = array3;
                        array4[num3] += this.outputProbs[j];
                        array[j].setAlpha(this.probCurrentFrame[j]);
                    }
                }
            }
            j = 0;
            while (j < this.graph.size())
            {
                Node      node      = this.graph.getNode(j);
                HMMState  hmmstate2 = null;
                SenoneHMM senoneHMM = null;
                if (node.isType("STATE"))
                {
                    hmmstate2 = (HMMState)node.getObject();
                    senoneHMM = (SenoneHMM)hmmstate2.getHMM();
                    if (!hmmstate2.isEmitting())
                    {
                        goto IL_26F;
                    }
                }
                else
                {
                    if (!this.graph.isInitialNode(node))
                    {
                        goto IL_26F;
                    }
                    array[j].setAlpha(float.MinValue);
                    this.probCurrentFrame[j] = float.MinValue;
                }
IL_35D:
                j++;
                continue;
IL_26F:
                this.probCurrentFrame[j] = float.MinValue;
                node.startIncomingEdgeIterator();
                while (node.hasMoreIncomingEdges())
                {
                    Node  source2 = node.nextIncomingEdge().getSource();
                    int   num4    = this.graph.indexOf(source2);
                    float num5;
                    if (source2.isType("STATE"))
                    {
                        HMMState hmmstate3 = (HMMState)source2.getObject();
                        if (!BaumWelchLearner.assertionsDisabled && hmmstate3.isEmitting() && hmmstate3.getHMM() != senoneHMM)
                        {
                            throw new AssertionError();
                        }
                        if (!hmmstate3.isEmitting())
                        {
                            num5 = 0f;
                        }
                        else
                        {
                            num5 = senoneHMM.getTransitionProbability(hmmstate3.getState(), hmmstate2.getState());
                        }
                    }
                    else
                    {
                        num5 = 0f;
                    }
                    this.probCurrentFrame[j] = this.logMath.addAsLinear(this.probCurrentFrame[j], this.probCurrentFrame[num4] + num5);
                }
                array[j].setAlpha(this.probCurrentFrame[j]);
                goto IL_35D;
            }
        }