示例#1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Updates the layer. </summary>
        ///
        /// <param name="PWhichLayer">  The which layer. </param>
        /// <param name="PForward">     True to forward. </param>
        /// <param name="PWeights">     The weights. </param>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        private void UpdateLayer(int PWhichLayer, bool PForward, AutoencoderWeights PWeights)
        {
            int beginlayer = PWhichLayer - 1;

            if (PForward)
            {
                Utility.WithinBounds("Cannot update this layer!!!", PWhichLayer, 1, numlayers);
            }
            else
            {
                Utility.WithinBounds("Cannot update this layer!!!", PWhichLayer, 0, numlayers - 1);
                beginlayer = PWhichLayer + 1;
            }
            RestrictedBoltzmannMachineLayer thislayer     = layers[PWhichLayer];
            RestrictedBoltzmannMachineLayer previouslayer = layers[beginlayer];
            double input = 0;

            double[] states = previouslayer.GetStates();
            for (int i = 0; i < thislayer.Count; i++)
            {
                for (int j = 0; j < previouslayer.Count; j++)
                {
                    if (!PForward)
                    {
                        input += PWeights.GetWeightSet(beginlayer - 1).GetWeight(i, j) * states[j];
                    }
                    else
                    {
                        input += PWeights.GetWeightSet(beginlayer).GetWeight(j, i) * states[j];
                    }
                }
                thislayer.SetState(i, input);
                input = 0;
            }
        }
示例#2
0
 private void AddLayer(RestrictedBoltzmannMachineLayer PLayer)
 {
     learnrate.preLearningRateBiases.Add(DEFAULT_RATE_BIAS);
     learnrate.preMomentumBiases.Add(DEFAULT_MOMENTUM);
     learnrate.fineLearningRateBiases.Add(DEFAULT_RATE_BIAS);
     if (layers.Count >= 1)
     {
         learnrate.preLearningRateWeights.Add(DEFAULT_RATE_WEIGHT);
         learnrate.preMomentumWeights.Add(DEFAULT_MOMENTUM);
         learnrate.fineLearningRateWeights.Add(DEFAULT_RATE_WEIGHT);
     }
     layers.Add(PLayer);
 }
示例#3
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Updates the layer backward pre train described by PWhich. </summary>
        ///
        /// <param name="PWhich">   The which. </param>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        private void UpdateLayerBackwardPreTrain(int PWhich)
        {
            Utility.WithinBounds("Cannot update this layer!!!", PWhich, numlayers - 1);
            RestrictedBoltzmannMachineLayer thislayer = layers[PWhich];
            RestrictedBoltzmannMachineLayer nextlayer = layers[PWhich + 1];
            double input = 0;

            double[] states = nextlayer.GetStates();
            for (int i = 0; i < thislayer.Count; i++)
            {
                for (int j = 0; j < nextlayer.Count; j++)
                {
                    input += recognitionweights.GetWeightSet(PWhich).GetWeight(i, j) * states[j];
                }
                thislayer.SetState(i, input);
                input = 0;
            }
        }