Skip to content

Allow both every and once args to be defined in Events.* #1541

@ydcjeff

Description

@ydcjeff

🚀 Feature

Allow users to define both every and once arguments in Events.*
The use case is I want to log the training loss at the first iteration to check that the loss makes sense or not, and then log the training loss at every iteration.

As of today per Events docs, we can use like

e = Events.ITERATION_COMPLETED(every=100) | Events.ITERATION_COMPLETED(once=1)
@engine.on(e)
def log_loss(engine):
    ...

It would be more useful if we can use like

e = Events.ITERATION_COMPLETED(every=100, once=1)
@engine.on(e)
def log_loss(engine):
    ...

Comments are welcome!

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