Skip to content

Cancellation in Image Classification (fixes #4632) #4650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jan 17, 2020
Prev Previous commit
Next Next commit
Adding CheckAlive method with exception handling
  • Loading branch information
antoniovs1029 committed Jan 14, 2020
commit 54d030929787a25c1037d9a94dda3b5b1de15b1b
13 changes: 13 additions & 0 deletions src/Microsoft.ML.Vision/ImageClassificationTrainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,19 @@ private void TrainAndEvaluateClassificationLayerCore(int epoch, float learningRa
}
}

private void CheckAlive()
{
try
{
Host.CheckAlive();
}
catch(OperationCanceledException e)
{
TryCleanupTemporaryWorkspace();
throw;
}
}

private void TryCleanupTemporaryWorkspace()
{
if (_cleanupWorkspace && Directory.Exists(_options.WorkspacePath))
Expand Down