Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uninformative error message when using sim.compile on a network with no probed outputs #203

Open
xchoo opened this issue Feb 12, 2021 · 0 comments

Comments

@xchoo
Copy link
Member

xchoo commented Feb 12, 2021

If you use the sim.compile method on a NengoDL model with no probed outputs, the following error message is thrown:

Traceback (most recent call last):
  File ".\test_dl_probe_out.py", line 15, in <module>
    sim.compile(
  File "d:\xchoo\git\nengo\nengo\utils\magic.py", line 181, in __call__
    return self.wrapper(self.__wrapped__, self.instance, args, kwargs)
  File "d:\xchoo\git\nengo-dl\nengo_dl\simulator.py", line 67, in require_open
    return wrapped(*args, **kwargs)
  File "d:\xchoo\git\nengo\nengo\utils\magic.py", line 181, in __call__
    return self.wrapper(self.__wrapped__, self.instance, args, kwargs)
  File "d:\xchoo\git\nengo-dl\nengo_dl\simulator.py", line 50, in with_self
    output = wrapped(*args, **kwargs)
  File "d:\xchoo\git\nengo-dl\nengo_dl\simulator.py", line 801, in compile
    metrics = self._standardize_data(
  File "d:\xchoo\git\nengo-dl\nengo_dl\simulator.py", line 1766, in _standardize_data
    f"Number of elements ({len(data)}) in "
IndexError: list index out of range

Minimum working example:

import nengo
import nengo_dl
import numpy as np
import tensorflow as tf

with nengo.Network() as model:
    inp = nengo.Node(np.ones(10))
    x = nengo_dl.Layer(tf.keras.layers.Dense(10))(inp)

    out = nengo.Probe(x)  # Comment out this line for error to be thrown

with nengo_dl.Simulator(model, minibatch_size=50) as sim:
    sim.compile(
        metrics=["accuracy"],
    )

While I acknowledge that the probe is logically necessary when constructing the NengoDL network, if you accidentally omit the probes, the error message thrown by the compilation step should be more informative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant