Engine - Continue run throws error because epoch_length is None
See original GitHub issue🐛 Bug description
I am using an engine such that it runs a previously undefined number of iterations with an infinite iterator. Epoch will be terminated in the process function with engine.terminate()
.
I am always running the engine for only one epoch, because I need to do some calculations outside the engines framework and then continue the engine to run one further epoch with engine.run(itertools.counter(start=0), max_epochs=engine.state.epoch + 1)
.
I get an error in engine._is_done
because engine.state.epoch_length
is None
. Is this the intended behavior? Do I have to set epoch_length
explicitly?
Here is a minimum example to reproduce the error:
import itertools
from ignite.engine import Engine
def _run_iteration(engine, counter):
if counter > 2:
# same behavior observed for engine.terminate_epoch()
engine.terminate()
if __name__ == '__main__':
engine = Engine(_run_iteration)
# run one epoch
engine.run(itertools.count(start=0), max_epochs=engine.state.epoch + 1)
# epoch length is None after run:
print(engine.state.epoch_length)
# running another epoch throws the error:
engine.run(itertools.count(start=0), max_epochs=engine.state.epoch + 1)
Thanks in advance!
Environment
- PyTorch Version (e.g., 1.4): 1.5.1
- Ignite Version (e.g., 0.3.0): 0.4.2
- OS (e.g., Linux): Windows
- How you installed Ignite (
conda
,pip
, source): pip - Python version: 3.7.7
- Any other relevant information: -
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Make node.js not exit on error - Stack Overflow
Attempting to resume application code without properly recovering from the exception can cause additional unforeseen and unpredictable issues. Exceptions thrown ...
Read more >Check Engine Light Off But Code Still There
If the check engine light is off, but you see an error code, it may be a pending code stored by the vehicle's...
Read more >Stop Vehicle Leave Engine Running Error Message - YouTube
Stop vehicle leave engine running message.caused by a weak battery. battery replacement has fixed this issue on this Mercedes Benz C Class ...
Read more >Rough Running Engine - James on Engines #2
If you find yourself with a rough running engine, you've found the right post. Find out the common causes and how your mechanic...
Read more >Is Your Engine Misfiring? Here are 6 Possible Causes
A misfire can be caused by a myriad of issues. However continuing to run an engine that is misfiring can cause catastrophic damage...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@fco-dv could you please take a look at this issue and propose a way to fix it along the way with https://github.com/pytorch/ignite/pull/1333 which actually shouldn’t introduce
state.restart
as it was discussed in the corresponding issue.@alxlampe thanks for the details !
Yes, that’s true that
engine.state.max_epochs = None
is to restart the Engine from the begining and not continue. Currently, if we would like to continue,epoch_length
is sort of implicitly required. It is a bug as in your case user can stop the execution during the first epoch of a run withepoch_length=None
andepoch_length
is not set… Let me think what can be done for that. Maybe, a solution is to set unknownepoch_length
onengine.terminate_epoch()
orengine.terminate()
…Yes, this is something to explore
A refactor like that may also make sense… Let’s see what is more interesting: this point or above one.