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; } }
public object Clone() { AutoencoderWeights retval = new AutoencoderWeights(); retval.numweightsets = numweightsets; retval.weights = new RBMWeightSet[numweightsets]; for (int i = 0; i < numweightsets; i++) { retval.weights[i] = (RBMWeightSet)weights[i].Clone(); } return(retval); }
internal Autoencoder(List <RBMLayer> PLayers, AutoencoderLearningRate PTrainingInfo , IWeightInitializer PWInitializer) { numlayers = PLayers.Count; layers = PLayers.ToArray(); learnrate = PTrainingInfo; recognitionweights = new AutoencoderWeights(numlayers, layers, PWInitializer); generativeweights = new AutoencoderWeights(numlayers, layers, PWInitializer); errorobservers = new List <IErrorObserver>(); InitBiases(PWInitializer); InitTrainingData(); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Pre training complete. </summary> /// /// <exception cref="Exception"> Thrown when an exception error condition occurs. </exception> //////////////////////////////////////////////////////////////////////////////////////////////////// public void PreTrainingComplete() { if (!pretraining) { throw new AutoEncoderException("You can only call PreTrainingComplete() once!"); } pretraining = false; for (int i = 0; i < numlayers; i++) { generativeweights = (AutoencoderWeights)recognitionweights.Clone(); } }
public void PreTrainingComplete() { if (!pretraining) { throw new Exception("You have already called PreTrainingComplete()!" + " Don't call it twice!"); } pretraining = false; for (int i = 0; i < numlayers; i++) { generativeweights = (AutoencoderWeights)recognitionweights.Clone(); } }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Creates a new object that is a copy of the current instance. </summary> /// /// <returns> A new object that is a copy of this instance. </returns> /// /// <seealso cref="M:System.ICloneable.Clone()"/> //////////////////////////////////////////////////////////////////////////////////////////////////// public object Clone() { AutoencoderWeights retval = new AutoencoderWeights { numweightsets = numweightsets, weights = new RestrictedBoltzmannMachineWeightSet[numweightsets] }; for (int i = 0; i < numweightsets; i++) { retval.weights[i] = (RestrictedBoltzmannMachineWeightSet)weights[i].Clone(); } return(retval); }