/// <summary> /// Select a pattern and shuffle it (if shuffle is enabled). /// </summary> /// <param name="position">The index of the pattern.</param> public void SelectShuffledPattern(int position) { Pattern pattern = _patterns[position]; pattern.SyncInputTo(_inputPattern, _config.Basic); if (_config.ShuffleEnable.Value) { for (int i = 0; i < _inputPattern.Length; i++) { _inputPattern[i] = _config.ShuffleInputNoiseSwap(_inputPattern[i]); } } pattern.SyncTrainingTo(_outputTraining, _config.Basic); if (!_config.Basic.QuietModeEnable.Value) { if (PatternSelectionChanged != null) { PatternSelectionChanged(this, new PatternPositionEventArgs(pattern, position)); } if (InputChanged != null) { InputChanged(this, EventArgs.Empty); } if (TrainingChanged != null) { TrainingChanged(this, EventArgs.Empty); } } }
/// <summary> /// Count matching (successful trained) patterns. /// </summary> /// <returns>The number of matching patterns</returns> public int CountSuccessfulPatterns() { //backup input data double[] bkp = _inputPattern; _inputPattern = new double[bkp.Length]; bkp.CopyTo(_inputPattern, 0); _network.FirstLayer.BindActivity(_inputPattern); //loop through patterns int c = 0; Pattern pattern = null; for (int i = 0; i < _patterns.Count; i++) { pattern = (Pattern)_patterns[i]; pattern.SyncInputTo(_inputPattern, _config.Basic); _network.CalculateFeedforward(); if (_network.LastLayer.EvaluateBiggestOutputNeuron() == pattern.Classification) { c++; } } //restore input data and network. _inputPattern = bkp; _network.FirstLayer.BindActivity(_inputPattern); _network.CalculateFeedforward(); return(c); }
/// <summary> /// Select a pattern. /// </summary> /// <param name="position">The index of the pattern.</param> public void SelectPattern(int position) { Pattern pattern = _patterns[position]; pattern.SyncInputTo(_inputPattern, _config.Basic); pattern.SyncTrainingTo(_outputTraining, _config.Basic); if (!_config.Basic.QuietModeEnable.Value) { if (PatternSelectionChanged != null) { PatternSelectionChanged(this, new PatternPositionEventArgs(pattern, position)); } if (InputChanged != null) { InputChanged(this, EventArgs.Empty); } if (TrainingChanged != null) { TrainingChanged(this, EventArgs.Empty); } } }