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

More informative error message for input data with wrong shape #154

Open
arvoelke opened this issue Jun 6, 2020 · 0 comments
Open

More informative error message for input data with wrong shape #154

arvoelke opened this issue Jun 6, 2020 · 0 comments

Comments

@arvoelke
Copy link
Contributor

arvoelke commented Jun 6, 2020

Context: nengo/nengo-examples#26

Taking an introductory example (such as docs/examples/from-nengo.ipynb) and modifying:

with nengo_dl.Simulator(net) as sim:
    sim.run(1.0, data={inpt: np.reshape(np.linspace(-1, 1, 1000), 
                                        (1, 1000, 1))})

to:

with nengo_dl.Simulator(net) as sim:
    sim.run(1.0, data={inpt: np.linspace(-1, 1, 1000)})

results in a stack trace and error message that is difficult to understand:

~/anaconda3/envs/*/lib/python3.7/site-packages/nengo_dl/simulator.py in _call_keras(self, func_type, x, y, n_steps, stateful, **kwargs)
    971         # maybe move it into a callback where the generated data is available?
    972 
--> 973         x = self._generate_inputs(x, n_steps=n_steps)
    974         self._check_data(
    975             x,

~/anaconda3/envs/*/lib/python3.7/site-packages/nengo_dl/simulator.py in _generate_inputs(self, data, n_steps)
   1814             data_batch = data_steps = None
   1815         else:
-> 1816             data_batch, data_steps = next(iter(data.values())).shape[:2]
   1817 
   1818         batch_size = self.minibatch_size if data_batch is None else data_batch

ValueError: not enough values to unpack (expected 2, got 1)

This kind of issue seems likely for people who are new to libraries like TensorFlow and are unfamiliar with array shaping. A more helpful error message could be provided.

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