Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Early Stopping Hook #386

Open
miguelvr opened this issue Feb 10, 2020 · 2 comments
Open

Early Stopping Hook #386

miguelvr opened this issue Feb 10, 2020 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@miguelvr
Copy link
Contributor

❓ Questions and Help

I'm trying to implement an early stopping hook that interacts with other custom hooks that I have implemented, but I'm having trouble of getting a sensible way of sending a stop signal to the ClassyTrainer.

The only way I managed to get it working was this:

    def on_loss_and_meter(
        self, task: "tasks.ClassyTask", local_variables: Dict[str, Any]
    ) -> None:
        # FIXME: Ugly hack
        task.done_training = lambda: True
        logging.info("early stopping")

Is there a cleaner way of achieving this in the current state of the project?

@vreis
Copy link
Contributor

vreis commented Feb 11, 2020

Yea, I agree this is hacky. There's no better solution right now.

We could add an exception that would be used to exit training, and that would make this much cleaner. I was considering doing that for other reasons anyway -- let's try to get this on the v0.3 release.

On another note: instead of making a hook for early stopping, I would probably consider overriding ClassificationTask.on_phase_end and add whatever logic is needed there.

@vreis vreis self-assigned this Feb 11, 2020
@vreis vreis added the enhancement New feature or request label Feb 11, 2020
@miguelvr
Copy link
Contributor Author

On another note: instead of making a hook for early stopping, I would probably consider overriding ClassificationTask.on_phase_end and add whatever logic is needed there.

You mean as a solution for now, or as a permanent solution?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants