-
-
Notifications
You must be signed in to change notification settings - Fork 692
DATALOADER_STOP_ITERATION should not be triggered if Engine.run(data=None, ...) #3190
Copy link
Copy link
Closed
Labels
Description
Reported in this issue: #3189 (comment)
Repro code:
from ignite.engine import Engine, Events
max_epochs = 4
dataset = range(10)
def training_step(engine, _):
print(f"- {engine.state.epoch} / {engine.state.max_epochs} | {engine.state.iteration}")
print(f"- batch: {next(engine.state.dataiter)}")
print('-'*120)
trainer = Engine(training_step)
trainer.state.dataiter = iter(dataset)
@trainer.on(Events.DATALOADER_STOP_ITERATION)
def init_data_iter():
print('THIS SHOULD NOT BE CALLED')
trainer.state.dataiter = iter(dataset)
trainer.run(max_epochs=max_epochs, epoch_length=4)gives the output:
- 1 / 4 | 1
- batch: 0
------------------------------------------------------------------------------------------------------------------------
- 1 / 4 | 2
- batch: 1
------------------------------------------------------------------------------------------------------------------------
- 1 / 4 | 3
- batch: 2
------------------------------------------------------------------------------------------------------------------------
- 1 / 4 | 4
- batch: 3
------------------------------------------------------------------------------------------------------------------------
THIS SHOULD NOT BE CALLED
- 2 / 4 | 5
- batch: 0
------------------------------------------------------------------------------------------------------------------------
- 2 / 4 | 6
- batch: 1
------------------------------------------------------------------------------------------------------------------------
- 2 / 4 | 7
- batch: 2
------------------------------------------------------------------------------------------------------------------------
- 2 / 4 | 8
- batch: 3
------------------------------------------------------------------------------------------------------------------------
THIS SHOULD NOT BE CALLED
- 3 / 4 | 9
- batch: 0
------------------------------------------------------------------------------------------------------------------------
- 3 / 4 | 10
- batch: 1
------------------------------------------------------------------------------------------------------------------------
- 3 / 4 | 11
- batch: 2
------------------------------------------------------------------------------------------------------------------------
- 3 / 4 | 12
- batch: 3
------------------------------------------------------------------------------------------------------------------------
THIS SHOULD NOT BE CALLED
- 4 / 4 | 13
- batch: 0
------------------------------------------------------------------------------------------------------------------------
- 4 / 4 | 14
- batch: 1
------------------------------------------------------------------------------------------------------------------------
- 4 / 4 | 15
- batch: 2
------------------------------------------------------------------------------------------------------------------------
- 4 / 4 | 16
- batch: 3
------------------------------------------------------------------------------------------------------------------------
Reactions are currently unavailable