Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
seminar-breakout
Commits
dbc0b36e
Commit
dbc0b36e
authored
Jul 16, 2020
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CheckNumerics callbacks
parent
07e28eea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
8 deletions
+17
-8
tensorpack/callbacks/graph.py
tensorpack/callbacks/graph.py
+17
-8
No files found.
tensorpack/callbacks/graph.py
View file @
dbc0b36e
...
...
@@ -219,18 +219,27 @@ class DumpTensorAsImage(Callback):
cv2
.
imwrite
(
fname
,
res
.
astype
(
'uint8'
))
class
CheckNumerics
(
Callback
):
class
CheckNumerics
(
RunOp
):
"""
When triggered, c
heck variables in the graph for NaN and Inf.
Raise
exceptions
if such an error is found.
C
heck variables in the graph for NaN and Inf.
Raise
an exception
if such an error is found.
"""
def
_setup_graph
(
self
):
_chief_only
=
True
def
__init__
(
self
,
run_as_trigger
=
True
,
run_step
=
False
):
"""
Args: same as in :class:`RunOp`.
"""
super
()
.
__init__
(
self
.
_get_op
,
run_as_trigger
=
run_as_trigger
,
run_step
=
run_step
)
def
_get_op
(
self
):
vars
=
tf
.
trainable_variables
()
ops
=
[
tf
.
check_numerics
(
v
,
"CheckNumerics['{}']"
.
format
(
v
.
op
.
name
))
.
op
for
v
in
vars
]
self
.
_check_op
=
tf
.
group
(
*
ops
)
def
_trigger
(
self
):
self
.
_check_op
.
run
()
check_op
=
tf
.
group
(
*
ops
,
name
=
"CheckAllNumerics"
)
return
check_op
try
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment