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

LSTMLayer should check input dimensionality #892

Open
f0k opened this issue Jan 22, 2018 · 1 comment
Open

LSTMLayer should check input dimensionality #892

f0k opened this issue Jan 22, 2018 · 1 comment
Labels
Milestone

Comments

@f0k
Copy link
Member

f0k commented Jan 22, 2018

When passing a two-dimensional input layer to LSTMLayer, it will break with an uninterpretable error message:

>>> lasagne.layers.LSTMLayer((10, 20), 30)
[...]
TypeError: 'numpy.float64' object cannot be interpreted as an index

The reason is that np.prod(()) returns 1.0 as a numpy.float64 instance when computing num_units: https://github.com/Lasagne/Lasagne/blob/master/lasagne/layers/recurrent.py#L863

We should check the input dimensionality and bail out earlier (both in LSTMLayer and GRULayer, maybe in others as well -- would be good to grep for np.prod and see if there are other instances that can fail in a similar fashion). Fixing this entails raising a ValueError for too small dimensionalities, and adding a test that checks whether the exception is raised correctly.

@f0k f0k added the easy label Jan 22, 2018
@f0k f0k added this to the v0.2 milestone Jan 22, 2018
@sameshl
Copy link

sameshl commented Aug 4, 2019

@f0k I am working on this. We need to raise ValueError when the input dimension is less than 3 right?

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

No branches or pull requests

2 participants