Skip to content

Commit

Permalink
add logic to reject parameters if they contain inf or 0
Browse files Browse the repository at this point in the history
  • Loading branch information
mjburton committed Dec 13, 2016
1 parent acc14f5 commit db8892d
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions gpfit/evaluate_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ def evaluate_fit(cnstr, x, fittype):
for n in vkn]).reshape(len(cnstr), len(vkn))
params = np.hstack([np.hstack([np.log(cn.left.c), ex])
for cn, ex in zip(cnstr, expos)])
y, _ = max_affine(x, params)
if np.inf in params or 0.0 in params or -np.inf in params:
pass
else:
y, _ = max_affine(x, params)

elif fittype == "SMA":
wvk = [vk for vk in cnstr.varkeys if vk.name == "w"][0]
Expand All @@ -49,7 +52,10 @@ def evaluate_fit(cnstr, x, fittype):
params = np.hstack([np.hstack([np.log(c**(alpha))] + [ex*alpha])
for c, ex in zip(cnstr.right.cs, expos)])
params = np.append(params, alpha)
y, _ = softmax_affine(x, params)
if np.inf in params or 0.0 in params or -np.inf in params:
pass
else:
y, _ = softmax_affine(x, params)

elif fittype == "ISMA":
wvk = [vk for vk in cnstr.varkeys if vk.name == "w"][0]
Expand All @@ -59,8 +65,11 @@ def evaluate_fit(cnstr, x, fittype):
[e[list(cnstr.varkeys["u_%d" % n])[0]] for e in cnstr.left.exps
for n in vkn]).reshape(len(cnstr.left.cs), len(vkn))
params = np.hstack([np.hstack([np.log(c**a)] + [e*a]) for c, e, a in
zip(cns.left.cs, expos, alphas)])
zip(cnstr.left.cs, expos, alphas)])
params = np.append(params, alphas)
y, _ = implicit_softmax_affine(x, params)
if np.inf in params or 0.0 in params or -np.inf in params:
pass
else:
y, _ = implicit_softmax_affine(x, params)

return y

0 comments on commit db8892d

Please sign in to comment.