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

Why the bcast is needed in create_param()? #912

Closed
david-leon opened this issue Aug 2, 2018 · 2 comments
Closed

Why the bcast is needed in create_param()? #912

david-leon opened this issue Aug 2, 2018 · 2 comments

Comments

@david-leon
Copy link

In create_param(), these two lines confuse me:

        bcast = tuple(s == 1 for s in shape)
        spec = theano.shared(spec, broadcastable=bcast)

I'm wondering what the bcast is for, especially these two lines will cause theano exception TypeError: Cannot convert Type TensorType(float32, vector) (of Variable Elemwise{add,no_inplace}.0) into Type TensorType(float32, (True,)) when shape arg is set to [1]

@nouiz
Copy link

nouiz commented Aug 6, 2018 via email

@f0k
Copy link
Member

f0k commented Oct 18, 2018

Sorry for the late reply. Lasagne has partial information on the input shapes and full information on the parameter shapes, and it uses this to set the correct broadcast patterns on Theano variables (which do not have any shape information at all). This allows some expressions using the outputs of Lasagne networks to work out of the box that would fail otherwise (see #715 for why this was introduced in the first place). On the downside, it requires extra care about broadcast patterns in user-provided variables.
Closing this issue since it was only a question, but please feel free to post how you got this error message and we can look into improving the documentation or failing earlier with a more useful message (and double-check it's not a bug in Lasagne).

@f0k f0k closed this as completed Oct 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants