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

Dense function does not support tensor? #1480

Closed
ziyiyin97 opened this issue Jan 27, 2021 · 2 comments
Closed

Dense function does not support tensor? #1480

ziyiyin97 opened this issue Jan 27, 2021 · 2 comments

Comments

@ziyiyin97
Copy link

Hi Flux developers,

I am now doing some comparisons between pytorch and flux and one of the problems I found with Flux makes coding a little bit more difficult:

If I have a 4D tensor in size_x, size_y, channels, batch size, e.g.x=randn(10*10*3*20)
then if I set up a dense layer by Layer = Dense(3,5)
then Layer(x) will report an error
ERROR: MethodError: no method matching *(::Array{Float32,2}, ::Array{Float32,4})
simply because Dense does not accept >=3D tensors,

while in PyTorch, nn.Linear could deal with multi-dimensional tensors easily as long as the channel is at the last index.

Is it a good idea for Flux to advise Dense layers as what Torch did? e.g. Conv function does a good job for multi-dimensional tensors just like what Torch did.

Thanks!

Francis

@darsnack
Copy link
Member

Hi, welcome to Flux! I believe this should already be fixed in #1405

@darsnack
Copy link
Member

Closing but feel free to reopen if the PR did not address your concern!

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

2 participants