You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As described in #358, It would be relatively simple to add invalid value detection to Stable-Baselines.
Adding CheckNaNTensorFlow to the losses, and use tf.add_check_numerics_ops in the policies, allows invalid value detection and prevents check_numerics from wrapping over evey operation in the graph (tf.add_check_numerics_ops does this by default).
Code example
classCheckNaNTensorFlow:
def__init__(self):
self.check_nan_ops= []
self.old_ops= []
def__enter__(self):
# wrap list so we have a copy of the current list, as list are mutableself.old_ops=list(tf.get_default_graph().get_operations())
def__exit__(self):
foropintf.get_default_graph().get_operations():
ifnotopinself.old_ops:
try:
self.check_nan_ops.append(tf.check_numerics(op, ""))
exceptTypeError: # things like reshape or conditional operations are skippedpasswithCheckNaNTensorFlow() astf_nan:
... # define the TF graph you want to check heresess.run([val_1, val_2] +tf_nan.check_nan_ops, td_map) # add to run
Additional context
This will probably add some overhead, my guess only as much as an if instruction. On CPU branch prediction should not bother too much of the performance, it might however hurt GPU performance significanlty, this needs verifing.
The text was updated successfully, but these errors were encountered:
As described in #358, It would be relatively simple to add invalid value detection to Stable-Baselines.
Adding
CheckNaNTensorFlow
to the losses, and usetf.add_check_numerics_ops
in the policies, allows invalid value detection and preventscheck_numerics
from wrapping over evey operation in the graph (tf.add_check_numerics_ops
does this by default).Code example
Additional context
This will probably add some overhead, my guess only as much as an if instruction. On CPU branch prediction should not bother too much of the performance, it might however hurt GPU performance significanlty, this needs verifing.
The text was updated successfully, but these errors were encountered: