ZeroDivisionError: integer division or modulo by zero解决记录
运行代码时,出现ZeroDivisionError: integer division or modulo by zero问题,具体如下:Traceback (most recent call last):File "./tools/train_net.py", line 51, in <module>launch(File "./fastreid/engine/launch.py",
·
运行代码时,出现ZeroDivisionError: integer division or modulo by zero问题,具体如下:
Traceback (most recent call last):
File "./111/22.py", line 51, in <module>
launch(
File "./111/123/launch.py", line 71, in launch
main_func(*args)
File "./111/22.py", line 45, in main
return trainer.train()
File "./0123/123/defaults.py", line 364, in train
super().train(self.start_epoch, self.max_epoch, self.iters_per_epoch)
File "./0123/123/train_loop.py", line 147, in train
self.after_epoch()
File "./0123/123/train_loop.py", line 181, in after_epoch
h.after_epoch()
File "./0123/123/hooks.py", line 261, in after_epoch
self._scheduler["lr_sched"].step()
File "/home/user/.local/lib/python3.8/site-packages/torch/optim/lr_scheduler.py", line 154, in step
values = self.get_lr()
File "/home/user/.local/lib/python3.8/site-packages/torch/optim/lr_scheduler.py", line 513, in get_lr
elif (self.last_epoch - 1 - self.T_max) % (2 * self.T_max) == 0:
ZeroDivisionError: integer division or modulo by zero
主要原因:
主要是数据量比较小,参数设置epoch_size=10,导致计算得到的运行轮数epoch_size小于10,从而epoch_size // 10结果为0
解决方案:
把参数设置的.yml文件中, 每次迭代输出10次信息更改成1,即epoch_size=10更改为epoch_size=1。成功解决ZeroDivisionError: integer division or modulo by zero问题,特此记录!!!
更多推荐
已为社区贡献11条内容
所有评论(0)