-
-
Notifications
You must be signed in to change notification settings - Fork 623
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
Filters don't work on custom events #1555
Comments
The issue appears to be some dependence on this map here: ignite/ignite/engine/events.py Line 356 in 3c8b781
I have not dug through the code to see what the dependence actually is, but it seems I should be able to do |
Hey @amatsukawa, nice to see you here again :) thanks for reporting, I'll take a look ! |
Well, it is a usage issue and bad documentation. Here is how it should be from ignite.engine import Engine, EventEnum
class TestEvents(EventEnum):
TEST_EVENT = 'test_event'
def train_step(engine, batch):
engine.fire_event(TestEvents.TEST_EVENT)
engine.state.test_event += 1
engine = Engine(train_step)
engine.register_events(*TestEvents, event_to_attr={TestEvents.TEST_EVENT: "test_event"})
@engine.on(TestEvents.TEST_EVENT(every=3))
def foo(engine):
print("hello world", engine.state.test_event)
def forever():
while True:
yield 0.
engine.run(forever(), max_epochs=10, epoch_length=1) As we want to filter out events, we have to have event counters and thus define a map between event name and state attribute which should be also incremented... |
Ah, awesome! Thanks for the clarification! |
Actually @vfdev-5 just want to confirm one thing: is it necessary to increment |
Yes, currently it is necessary to increment state's attribute as we check when to skip handlers trigerring according to engine.register_events(*TestEvents, event_to_attr={TestEvents.TEST_EVENT: "test_event"}) and this |
I added some docs changes in #1587. @vfdev-5 Please have a look if that works out, then I can re-create the docs and finish the PR. |
CallableEventWithFilter
does not work with custom events:The error is:
The text was updated successfully, but these errors were encountered: