Example #1
0
        private void ComputeTopLayer(Sequence pSequence, out Matrix <float> rawOutputLayer, RunningMode runningMode, bool outputRawScore)
        {
            var numStates        = pSequence.States.Length;
            var lastLayerOutputs = layersOutput[forwardHiddenLayers.Count - 1];

            //Calculate output layer
            Matrix <float> tmpOutputResult = null;

            if (outputRawScore)
            {
                tmpOutputResult = new Matrix <float>(numStates, OutputLayer.LayerSize);
            }

            OutputLayer.LabelShortList = pSequence.States.Select(state => state.Label).ToList();
            for (var curState = 0; curState < numStates; curState++)
            {
                var state = pSequence.States[curState];
                OutputLayer.ForwardPass(state.SparseFeature, lastLayerOutputs[curState]);
                OutputLayer.CopyNeuronTo(OutputCells[curState]);

                if (outputRawScore)
                {
                    OutputLayer.Cells.CopyTo(tmpOutputResult[curState], 0);
                }
            }

            rawOutputLayer = tmpOutputResult;
        }