Skip to content
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

DATALOADER_STOP_ITERATION should not be triggered if Engine.run(data=None, ...) #3190

Closed
vfdev-5 opened this issue Jan 22, 2024 · 0 comments · Fixed by #3217
Closed

DATALOADER_STOP_ITERATION should not be triggered if Engine.run(data=None, ...) #3190

vfdev-5 opened this issue Jan 22, 2024 · 0 comments · Fixed by #3217
Labels

Comments

@vfdev-5
Copy link
Collaborator

vfdev-5 commented Jan 22, 2024

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
------------------------------------------------------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant