public AutoencoderWeights(int PNumLayers, RBMLayer[] PLayers, IWeightInitializer PWInitializer) { numweightsets = PNumLayers - 1; weights = new RBMWeightSet[numweightsets]; for (int i = 0; i < numweightsets; i++) { weights[i] = new RBMWeightSet(PLayers[i].Count, PLayers[i + 1].Count, PWInitializer); } }
internal void Load(TextReader PFile) { numweightsets = int.Parse(PFile.ReadLine()); weights = new RBMWeightSet[numweightsets]; for (int i = 0; i < numweightsets; i++) { weights[i] = RBMWeightSet.Load(PFile); } }
public RBM(RBM PA) { visibles = (RBMLayer)PA.visibles.Clone(); hiddens = (RBMLayer)PA.hiddens.Clone(); weights = (RBMWeightSet)PA.weights.Clone(); learnrate = PA.learnrate; trainingdata = PA.trainingdata; numvisibles = PA.numvisibles; numhiddens = PA.numhiddens; }
private void InitWeights(IWeightInitializer PWeightInit) { weights = new RBMWeightSet(numvisibles, numhiddens, PWeightInit); for (int i = 0; i < numvisibles; i++) { for (int j = 0; j < numhiddens; j++) { weights.SetWeight(i, j, Utility.NextGaussian(0, 0.1)); } } }
public object Clone() { RBMWeightSet newweights = new RBMWeightSet(presize, postsize, new ZeroWeightInitializer()); for (int i = 0; i < presize; i++) { for (int j = 0; j < postsize; j++) { newweights.SetWeight(i, j, weights[i][j]); } } return(newweights); }
internal static RBMWeightSet Load(TextReader PFile) { RBMWeightSet retval = new RBMWeightSet(); retval.presize = int.Parse(PFile.ReadLine()); retval.weights = new double[retval.presize][]; retval.weightchanges = new double[retval.presize][]; for (int i = 0; i < retval.presize; i++) { retval.weights[i] = Utility.LoadArray(PFile); } retval.postsize = retval.weights[0].GetLength(0); for (int i = 0; i < retval.presize; i++) { retval.weightchanges[i] = new double[retval.postsize]; } return(retval); }
public static void Train(RBMLayer PLayerVis, RBMLayer PLayerHid, TrainingData PData , RBMLearningRate PLearnRate, RBMWeightSet PWeightSet) { weightset = PWeightSet; learnrate = PLearnRate; for (int i = 0; i < PLayerVis.Count; i++) { for (int j = 0; j < PLayerHid.Count; j++) { TrainWeight(i, j, CalculateTrainAmount(PData.posvis[i], PData.poshid[j] , PData.negvis[i], PData.neghid[j])); } TrainBias(PLayerVis, i, PData.posvis[i], PData.negvis[i]); } for (int j = 0; j < PLayerHid.Count; j++) { TrainBias(PLayerHid, j, PData.poshid[j], PData.neghid[j]); } }