protected virtual void OnLoopEnd(EventArgs e) { LoopEnded?.Invoke(this, e); }
protected void PlaybackLoop(int ReplaysToPlay, Keys RecordStart, Keys RecordStop) { ProcessRunning = true; bool menu = false; bool IsLoading = false; ReplaysPlayed = 0; try { FocusWindow(); // Start recording hotkey if (RecordStart != Keys.None && RecordStop != Keys.None) { Keyboard.KeyDown(RecordStart); Thread.Sleep(50); Keyboard.KeyUp(RecordStart); } // Main loop while (ProcessRunning) { MenuStateActive(ref menu); Thread.Sleep(500); if (!IsLoading && menu) { FocusWindow(); ReplaysPlayed++; // Check if all the replays have been played if (ReplaysPlayed > ReplaysToPlay) { ProgressText = "Queue finished"; break; } ProgressText = "Viewing replay " + ReplaysPlayed.ToString() + " / " + ReplaysToPlay.ToString(); // Navigate to next replay in game NavigateDefault(); IsLoading = true; } else if (IsLoading && !menu) { FocusWindow(); IsLoading = false; InMatchInputs(); } } } catch (IndexOutOfRangeException) { GameNotOpen(); } // Stop recording hotkey if (RecordStart != Keys.None && RecordStop != Keys.None) { Keyboard.KeyDown(RecordStop); Thread.Sleep(50); Keyboard.KeyUp(RecordStop); } if (ReplaysPlayed <= ReplaysToPlay) { ProgressText = "Queue interrupted"; } ProcessRunning = false; LoopEnded?.Invoke(this, new EventArgs()); }
public void Train() { int iloop = 0; training = true; try { net.Lock(); while (iloop < nLoops && training) { LoopBegin?.Invoke(new LoopBeginStepArg { LoopIndex = iloop, TotalLoops = nLoops, Trainer = this }); int iexample = 0; foreach (var example in trainingSet) { example.Input.Lock(); example.Output.Lock(); if (!training) { break; } Train(example); var error = ComputeExampleError(example); ExampleStep?.Invoke(new ExampleStepArg { Example = example, ExampleIndex = iexample, LoopIndex = iloop, TotalLoops = nLoops, Trainer = this, Error = error }); example.Input.UnLock(); example.Output.UnLock(); iexample++; } var trainingSetError = ComputeError(trainingSet); var validationError = ComputeError(validationSet); LoopEnded?.Invoke(new LoopStepEndedArg { LoopIndex = iloop, TotalLoops = nLoops, Trainer = this, TraningSetError = trainingSetError, ValidationSetError = validationError }); iloop++; } } finally { net.Unlock(); } }