[go: nahoru, domu]

Skip to content

Commit

Permalink
Add support for checking np.floating as well as float when summing at…
Browse files Browse the repository at this point in the history
…tributions.

PiperOrigin-RevId: 405737562
  • Loading branch information
mdreves authored and tfx-copybara committed Oct 26, 2021
1 parent 0c66788 commit 80a7dfb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tensorflow_model_analysis/metrics/attributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ def __init__(self, key: metric_types.AttributionsKey, absolute: bool):

def _sum(self, a: List[float], b: Union[np.ndarray, List[float]]):
"""Adds values in b to a at matching offsets."""
if isinstance(b, float) or (isinstance(b, np.ndarray) and b.size == 1):
if (isinstance(b, (float, np.floating)) or
(isinstance(b, np.ndarray) and b.size == 1)):
if len(a) != 1:
raise ValueError(
'Attributions have different array sizes {} != {}'.format(a, b))
Expand Down

0 comments on commit 80a7dfb

Please sign in to comment.