Skip to content

Commit 200e753

Browse files
ursktensorflower-gardener
authored andcommitted
Clean up exception handling for _call_fn_maybe_with_seed.
PiperOrigin-RevId: 565489383
1 parent 8e17749 commit 200e753

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tensorflow_probability/python/vi/csiszar_divergence.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@
6060
def _call_fn_maybe_with_seed(fn, args, *, seed=None):
6161
try:
6262
return nest_util.call_fn(functools.partial(fn, seed=seed), args)
63-
except: # pylint: disable=bare-except
64-
return nest_util.call_fn(fn, args)
63+
except (TypeError, ValueError) as e:
64+
if ("'seed'" in str(e) or ('one of *args or **kwargs' in str(e))):
65+
return nest_util.call_fn(fn, args)
66+
else:
67+
raise e
6568

6669

6770
class GradientEstimators(enum.Enum):

0 commit comments

Comments
 (0)