Skip to content

Train operation should be cancellable. #844

Closed

Description

@kant2002

System information

  • OS version/distro: All supported
  • .NET Version (eg., dotnet --info): All supported.

Issue

  • I attempt to write training of the models using API as part of internal pipeline
  • After I run pipeline.Train() I was not able to stop training using standard .NET CancellationToken API
  • Please provide ability to cancel such long running operation as training.

Activity

  1. Zruty0 commented on Sep 6, 2018

    @Zruty0
    Contributor

    With the new API we are going to expose IHostEnvironment to you (see https://github.com/dotnet/machinelearning/blob/master/src/Microsoft.ML.Core/Data/IHostEnvironment.cs).
    Here's how you can cancel a process using that:

    var env = new TlcEnvironment(); // Class name subject to change.
    var host = env.Register("some user name");
    
    var pipeline = ... // create pipeline using 'host'.
    pipeline.Fit(data);

    If you call host.StopExecution(), the training process will terminate with an exception.
    I am not sure why we discarded the standard CancellationToken API. It was definitely considered at that time, but I forgot what was the reason not to use it.

  2. kant2002 commented on Sep 9, 2018

    @kant2002
    ContributorAuthor

    @Zruty0 are the IHostEnvironment could be used in the 0.4.0, or I should use nightlies for accessing this functionality? I'm aware about API change, just do not research on new API yet.

  3. klausmh commented on Dec 4, 2018

    @klausmh
    Contributor

    Could you provide an example of "var pipeline = ... // create pipeline using 'host'." in the current version of ML.NET?

  4. codemzs commented on Jun 30, 2019

    @codemzs
    Member

    Done as part of #2797

  5. kant2002 commented on Jun 30, 2019

    @kant2002
    ContributorAuthor

    Thanks!

  6. ghost locked as resolved and limited conversation to collaborators on Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions