Skip to content

Commit 6358e21

Browse files
committed
fix printing problems when loss is big
1 parent 7379e1e commit 6358e21

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pymc3/variational/inference.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,11 @@ def _iterate_without_loss(self, _, step_func, progress, callbacks):
146146
def _iterate_with_loss(self, n, step_func, progress, callbacks):
147147
def _infmean(input_array):
148148
"""Return the mean of the finite values of the array"""
149-
return np.mean(np.asarray(input_array)[np.isfinite(input_array)])
149+
input_array = input_array[np.isfinite(input_array)].astype('float64')
150+
if len(input_array) == 0:
151+
return np.nan
152+
else:
153+
return np.mean(input_array)
150154
scores = np.empty(n)
151155
scores[:] = np.nan
152156
i = 0

0 commit comments

Comments
 (0)