训练一个深度学习检测模型,突然出现:
是因为next(batch_iterator),可能迭代器读出来的数据为空。
# load train data# 原先代码images, targets = next(batch_iterator)# 更改为:try:images, targets = next(batch_iterator)except:batch_iterator = iter(data_loader)images, targets = next(batch_iterator)