Skip to content

Commit e488fb2

Browse files
emilyfertigtensorflower-gardener
authored andcommitted
Fix in call to np.exp in the Numpy backend.
PiperOrigin-RevId: 456577290
1 parent bfa5748 commit e488fb2

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

tensorflow_probability/python/internal/backend/numpy/_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def _find_method_from_name(scope, name):
4646
child = scope[method[0]]
4747
else:
4848
child = getattr(scope, method[0])
49-
if len(method) == 1 or (len(method) == 2 and method[0] == 'np'):
49+
if len(method) == 1:
5050
return child
5151
return _find_method_from_name(child, method[1])
5252

tensorflow_probability/python/internal/backend/numpy/numpy_math.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,8 @@ def _alt_reduce_logsumexp(input_tensor, axis=None, keepdims=False):
363363
"""Alternative to SP logsumexp."""
364364
m = _max_mask_non_finite(input_tensor, axis=axis, keepdims=True)
365365
y = input_tensor - m
366-
y = np.exp(y, out=y)
367-
if not keepdims:
366+
y = np.exp(y)
367+
if not keepdims and y.size > 0:
368368
m = np.squeeze(m, axis=_astuple(axis))
369369
return m + np.log(np.sum(y, axis=_astuple(axis), keepdims=keepdims))
370370

0 commit comments

Comments
 (0)