The error stopiteration is reported when using next (ITER (data. Dataloader()). This is because when using next() When accessing an iterator that has been iterated, an error will be triggered: stopiteration, that is, after a round of iteration after the dataloader imports the data, it is found that there is no data when importing again, that is, after the Iterable is completed, stopiteration is triggered, and then the loop jumps out
resolvent:
Since there is no data when importing again, we can use a data loader.
Put the in train.py
inps, targets = next(self.batch_iterator)
Change to:
try:
inps, targets = next(self.batch_iterator)
except StopIteration:
self.batch_iterator = iter(data.DataLoader(self.train_dataset, self.args.batch_size, shuffle=True, num_workers=self.args.num_workers, collate_fn=detection_collate))
inps, targets = next(self.batch_iterator)
Problem solving.
Read More:
- Due to multi process — pychar debug breakpoint debugging encounter pychar dataloader will be stuck
- A stopiteration exception is thrown after Python next() completes
- How to Fix Sklearn ValueError: This solver needs samples of at least 2 classes in the data, but the data
- Anaconda opens Navigator to report an error and a web page appears Navigator Error An unexpected error occurred on Navigator start-up Report
- Running Python 3.7 web.py Runtimeerror: generator raised stopiteration exception occurred during test
- Solve the problem of There was an unexpected error (type=Internal Server Error, status=500) (using Thymeleaf to report an error)
- The project uses fastjason to report an error
- Design of MQ asynchronous collection report data
- Kibana was degraded from 7.0 to 6.8 and started to report an error
- Mybatis passes in multiple parameters to mapper. And uses @param details to report an error
- Using openfeign to remotely call the startup program to report an error
- Using nginx page to report an error occurred
- Java uses the createnewfile() method to report an error
- Vue uses SCSS dependency to report an error
- PHP under linux uses pdo-dblib to connect to mssql to report an error solution. Error message: SQLSTATE[01002] Adaptive Server connection failed (severity 9)
- Spring AOP uses AspectJ to report an exception that ‘the reference to the bean “mypointcut” cannot be resolved’
- Starting zookeeper to report an error already running as process
- Add PageHelper spring boot starter dependency to springboot and report an error
- Call Excel to report an error (the exception comes from HResult: 0x80010105 (RPC)_ SERVERFAULT))
- Use less.js to verify and report an error in the Vue file of vscode