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;
            }
            RBMLayer thislayer     = layers[PWhichLayer];
            RBMLayer 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;
            }
        }
Exemplo n.º 2
0
        private void UpdateVisibles()
        {
            double input = 0;

            double[] states = hiddens.GetStates();
            for (int i = 0; i < numvisibles; i++)
            {
                for (int j = 0; j < numhiddens; j++)
                {
                    input += weights.GetWeight(i, j) * states[j];
                }
                visibles.SetState(i, input);
                input = 0;
            }
        }
        private void UpdateLayerBackwardPreTrain(int PWhich)
        {
            Utility.WithinBounds("Cannot update this layer!!!", PWhich, numlayers - 1);
            RBMLayer thislayer = layers[PWhich];
            RBMLayer 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;
            }
        }