void IConfigurable.Rebind(ConfigNode node) { _node = node; if (_config == null) { _config = new TrainingConfig(_node); } else { _config.Node = _node; } }
/// <summary> /// Train the network using specialized strategies. /// </summary> /// <returns>Whether the training was successful.</returns> public bool Train(IControler controler, Progress progress) { TrainingConfig config = controler.TrainingConfiguration; BasicConfig basic = config.Basic; int patternCount = controler.PatternCount; int epochs = config.AutoTrainingEpochs.Value; int success = (int)(patternCount * config.AutoTrainingPercentSuccessful.Value); int howmany = controler.CountSuccessfulPatterns(); double LRinitial = basic.LearningRate.Value; double LRstep = LRinitial * 0.7 / epochs; double LRcurrent = LRinitial; if (howmany >= success) { return(true); } int timeout = epochs; while (timeout-- >= 0) { basic.LearningRate.Value = LRcurrent; if (progress != null) { progress((int)(100 * (epochs - (double)timeout) / epochs)); } for (int i = 0; i < patternCount; i++) { controler.SelectShuffledPattern(i); controler.NeuralNetwork.TrainCurrentPattern(true, false); } howmany = controler.CountSuccessfulPatterns(); if (howmany >= success) { basic.LearningRate.Value = LRinitial; return(true); } LRcurrent -= LRstep; } // CLEAN UP: //controler.CalculateCurrentNetwork(); basic.LearningRate.Value = LRinitial; return(false); }
/// <summary> /// Train the network using specialized strategies. /// </summary> /// <returns>Whether the training was successful.</returns> public bool Train(IControler controler, Progress progress) { TrainingConfig config = controler.TrainingConfiguration; int patternCount = controler.PatternCount; int epochs = config.AutoTrainingEpochs.Value; int success = (int)(patternCount * config.AutoTrainingPercentSuccessful.Value); int howmany = controler.CountSuccessfulPatterns(); if (howmany >= success) { return(true); } int timeout = epochs; while (timeout-- >= 0) { if (progress != null) { progress((int)(100 * (epochs - (double)timeout) / epochs)); } for (int i = 0; i < patternCount; i++) { controler.SelectShuffledPattern(i); if (controler.CalculateCurrentNetwork() != i) { controler.NeuralNetwork.TrainCurrentPattern(false, false); howmany = controler.CountSuccessfulPatterns(); if (howmany >= success) { return(true); } } } } // CLEAN UP: //controler.CalculateCurrentNetwork(); return(false); }
void IConfigurable.Rebind(ConfigNode node) { _node = node; if(_config == null) _config = new TrainingConfig(_node); else _config.Node = _node; }