コード例 #1
0
        public override void InitializeInternalTrainingParameters()
        {
            if (SparseFeatureSize > 0)
            {
                sparseFeatureToHiddenDeri = new Dictionary <int, Vector3> [LayerSize];
                for (var i = 0; i < LayerSize; i++)
                {
                    sparseFeatureToHiddenDeri[i] = new Dictionary <int, Vector3>();
                }

                if (sparseFeatureLearningRate == null)
                {
                    sparseFeatureLearningRate = new Vector4[LayerSize][];
                    sparseFeatureWeightsDelta = new Vector4[LayerSize][];
                    for (var i = 0; i < LayerSize; i++)
                    {
                        sparseFeatureLearningRate[i] = new Vector4[SparseFeatureSize];
                        sparseFeatureWeightsDelta[i] = new Vector4[SparseFeatureSize];
                    }
                }
            }

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

            cellDelta       = new Vector4[LayerSize];
            peepholeDelta   = new Vector3[LayerSize];
            CellWeightsDeri = new LSTMCellWeightDeri[LayerSize];
            for (var i = 0; i < LayerSize; i++)
            {
                CellWeightsDeri[i] = new LSTMCellWeightDeri();
            }
        }
コード例 #2
0
ファイル: LSTMLayer.cs プロジェクト: deTrident/RNNSharp
        public override void InitializeInternalTrainingParameters()
        {
            if (SparseFeatureSize > 0)
            {
                sparseFeatureToHiddenDeri = new Dictionary <int, Vector3> [LayerSize];
                for (var i = 0; i < LayerSize; i++)
                {
                    sparseFeatureToHiddenDeri[i] = new Dictionary <int, Vector3>();
                }
            }

            if (sparseFeatureToHiddenLearningRate == null)
            {
                if (SparseFeatureSize > 0)
                {
                    sparseFeatureToHiddenLearningRate = new Vector4[LayerSize][];
                    for (var i = 0; i < LayerSize; i++)
                    {
                        sparseFeatureToHiddenLearningRate[i] = new Vector4[SparseFeatureSize];
                    }
                }
            }

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

            CellWeightsDeri = new LSTMCellWeightDeri[LayerSize];
            for (var i = 0; i < LayerSize; i++)
            {
                CellWeightsDeri[i] = new LSTMCellWeightDeri();
            }

            if (lockerDenseFeature == null)
            {
                lockerDenseFeature = new object[LayerSize];
                for (int i = 0; i < LayerSize; i++)
                {
                    lockerDenseFeature[i] = new object();
                }
            }

            if (lockerSparseFeature == null)
            {
                lockerSparseFeature = new object[LayerSize];
                for (int i = 0; i < LayerSize; i++)
                {
                    lockerSparseFeature[i] = new object();
                }
            }

            if (cellLockers == null)
            {
                cellLockers = new object[LayerSize];
                for (int i = 0; i < LayerSize; i++)
                {
                    cellLockers[i] = new object();
                }
            }
        }