Skip to content

Commit

Permalink
Add error for NaN encoders
Browse files Browse the repository at this point in the history
  • Loading branch information
drasmuss committed Oct 30, 2019
1 parent b3d6caf commit bb8010a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Expand Up @@ -29,6 +29,8 @@ Release history
(`#226 <https://github.com/nengo/nengo-loihi/pull/226>`__)
- Connections now support ``Sparse`` transforms.
(`#240 <https://github.com/nengo/nengo-loihi/pull/240>`__)
- A more informative error message is raised if any encoders contain NaNs.
(`#251 <https://github.com/nengo/nengo-loihi/pull/251>`__)

**Changed**

Expand Down
7 changes: 7 additions & 0 deletions nengo_loihi/builder/ensemble.py
Expand Up @@ -83,6 +83,13 @@ def build_ensemble(model, ens):
if ens.normalize_encoders:
encoders /= npext.norm(encoders, axis=1, keepdims=True)

if np.any(np.isnan(encoders)):
raise BuildError(
"NaNs detected in %r encoders. This usually means that you had zero-length "
"encoders that were normalized, resulting in NaNs. Ensure all encoders "
"have non-zero length, or set `normalize_encoders=False`." % ens
)

# Build the neurons
gain, bias, max_rates, intercepts = get_gain_bias(ens, rng, model.intercept_limit)

Expand Down

0 comments on commit bb8010a

Please sign in to comment.