コード例 #1
0
ファイル: LSTMLayer.cs プロジェクト: deTrident/RNNSharp
        public override void CleanLearningRate()
        {
            if (SparseFeatureSize > 0)
            {
                for (var i = 0; i < LayerSize; i++)
                {
                    Array.Clear(sparseFeatureToHiddenLearningRate[i], 0, SparseFeatureSize);
                }
            }

            if (DenseFeatureSize > 0)
            {
                wDenseCellGate.CleanLearningRate();
                wDenseForgetGate.CleanLearningRate();
                wDenseInputGate.CleanLearningRate();
                wDenseOutputGate.CleanLearningRate();
            }

            peepholeLearningRate = new Vector3[LayerSize];
            cellLearningRate     = new Vector4[LayerSize];

            vecNormalLearningRate = new Vector4(RNNHelper.LearningRate, RNNHelper.LearningRate, RNNHelper.LearningRate,
                                                RNNHelper.LearningRate);
            vecNormalLearningRate3 = new Vector3(RNNHelper.LearningRate, RNNHelper.LearningRate, RNNHelper.LearningRate);

            vecNormalLearningRateFloat = new Vector <float>(RNNHelper.LearningRate);

            vecMaxGrad = new Vector4(RNNHelper.GradientCutoff, RNNHelper.GradientCutoff, RNNHelper.GradientCutoff,
                                     RNNHelper.GradientCutoff);
            vecMinGrad = new Vector4(-RNNHelper.GradientCutoff, -RNNHelper.GradientCutoff, -RNNHelper.GradientCutoff,
                                     -RNNHelper.GradientCutoff);

            vecMaxGrad3 = new Vector3(RNNHelper.GradientCutoff, RNNHelper.GradientCutoff, RNNHelper.GradientCutoff);
            vecMinGrad3 = new Vector3(-RNNHelper.GradientCutoff, -RNNHelper.GradientCutoff, -RNNHelper.GradientCutoff);
        }
コード例 #2
0
        public override void CleanLearningRate()
        {
            if (SparseFeatureSize > 0)
            {
                sparseFeatureToHiddenLearningRate = new Vector4[LayerSize][];
            }

            if (DenseFeatureSize > 0)
            {
                wDenseCellGate.CleanLearningRate();
                wDenseForgetGate.CleanLearningRate();
                wDenseInputGate.CleanLearningRate();
                wDenseOutputGate.CleanLearningRate();
            }

            peepholeLearningRate = new Vector3[LayerSize];
            cellLearningRate     = new Vector4[LayerSize];
            Parallel.For(0, LayerSize, parallelOption, i =>
            {
                if (SparseFeatureSize > 0)
                {
                    sparseFeatureToHiddenLearningRate[i] = new Vector4[SparseFeatureSize];
                }
            });

            vecNormalLearningRate = new Vector4(RNNHelper.LearningRate, RNNHelper.LearningRate, RNNHelper.LearningRate,
                                                RNNHelper.LearningRate);
            vecNormalLearningRate3 = new Vector3(RNNHelper.LearningRate, RNNHelper.LearningRate, RNNHelper.LearningRate);

            vecNormalLearningRateFloat = new Vector <float>(RNNHelper.LearningRate);

            vecMaxGrad = new Vector4(RNNHelper.GradientCutoff, RNNHelper.GradientCutoff, RNNHelper.GradientCutoff,
                                     RNNHelper.GradientCutoff);
            vecMinGrad = new Vector4(-RNNHelper.GradientCutoff, -RNNHelper.GradientCutoff, -RNNHelper.GradientCutoff,
                                     -RNNHelper.GradientCutoff);

            vecMaxGrad3 = new Vector3(RNNHelper.GradientCutoff, RNNHelper.GradientCutoff, RNNHelper.GradientCutoff);
            vecMinGrad3 = new Vector3(-RNNHelper.GradientCutoff, -RNNHelper.GradientCutoff, -RNNHelper.GradientCutoff);
        }