forked from shinya7y/UniverseNet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] add check isfinite hook (#5674)
* [Feature] add check isfinite hook * add isfinite hook * add isfinite hook * fix error * change qq group QRcode * change qq group QRcode * fix name * delete qrcode * fix * add check invalid loss hook * add test unit * fix logic
- Loading branch information
1 parent
682f03d
commit 3cef22d
Showing
7 changed files
with
83 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import torch | ||
from mmcv.runner.hooks import HOOKS, Hook | ||
|
||
|
||
@HOOKS.register_module() | ||
class CheckInvalidLossHook(Hook): | ||
"""Check invalid loss hook. | ||
This hook will regularly check whether the loss is valid | ||
during training. | ||
Args: | ||
interval (int): Checking interval (every k iterations). | ||
Default: 50. | ||
""" | ||
|
||
def __init__(self, interval=50): | ||
self.interval = interval | ||
|
||
def after_train_iter(self, runner): | ||
if self.every_n_iters(runner, self.interval): | ||
assert torch.isfinite(runner.outputs['loss']), \ | ||
runner.logger.info('loss become infinite or NaN!') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters