question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

🚀 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!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
vfdev-5commented, Jan 6, 2021

What about allowing both every and once in Events.* ? Can you reopen for that? I think i can’t

As I said previously, I think it can be a bit misleading. On the other hand if user would like to have both, this can be done with a custom filter:

e = Events.ITERATION_COMPLETED(event_filter=lambda _, ev: (ev % 100 == 0) or (ev == 1))
@engine.on(e)
def log_loss(engine):
    ...

See https://pytorch.org/ignite/engine.html#ignite.engine.events.Events

2reactions
vfdev-5commented, Jan 3, 2021

@ydcjeff thanks for feature request ! I was thinking about having every and once available together and IMO it can be a bit misleading inside a single event as you suggest: Events.ITERATION_COMPLETED(every=100, once=1)… However, I understand that it could be interesting to introduce something to simplify:

e = Events.ITERATION_COMPLETED(every=100) | Events.ITERATION_COMPLETED(once=1)

@sdesrozis what do you think ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Javascript event handler with parameters - Stack Overflow
// Let's use use good old function sytax function event_handler(event, arg) { console.log(event, arg); } // Assign the listener callback to a ...
Read more >
Unity Events, passing multiple arguments
I've been using Unity Events for a few weeks now, and whilst they ... UI system has events with a single parameter, but...
Read more >
EventTarget.addEventListener() - Web APIs | MDN
It allows adding more than one handler for an event. ... It works on any event target, not just HTML or SVG elements....
Read more >
Set up event parameters | Google Analytics 4 Properties
This guide shows you how to set up parameters for recommended events and custom events on your website so you can collect more...
Read more >
[GA4] Configure Google Analytics 4 in Google Tag Manager
Google Tag Manager allows you to set up and manage GA4 events all in one place. To send event data from Google Tag...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found