Skip to content

Conversation

@harryfei
Copy link

By supporting additional dimensions, the interface of Dense layer would be like this.

  • Input Shape: (in_features, d1, d2, d3, ..., N)
  • Ouput Shape: (out_features, d2, d2, d3,..., N)

Related discuss: #282

By supporting additional dimensions, the interface of Dense layer would be like this.
 * Input Shape: (in_features, d1, d2, d3, ..., N)
 * Ouput Shape: (out_features, d2, d2, d3,..., N)
@MikeInnes
Copy link
Member

Thanks! A couple comment before we can merge this –

I think it'd be cleaner to keep the current Dense definition as-is, perhaps with a AbstractVecOrMat type restriction. Then you can overload AbstractArray and do the needed reshaping.

You can do this in a single matmul by just reshaping the inputs/outputs to Dense appropriately, which would avoid extra copies and be more GPU-friendly.

@harryfei
Copy link
Author

harryfei commented Jul 3, 2018

I have no idea in my mind, could you explain more?

Update: Never mind, I get it.

@harryfei
Copy link
Author

I think we don't need this change anymore according to the above cleaner solution.
Should we add the reshape helper function in this repository? If it's Ok, I will create another PR. @MikeInnes

@MikeInnes
Copy link
Member

Sure, if you can update this PR with the reshape version, that works great for me.

@drozzy
Copy link

drozzy commented Nov 25, 2020

Any eta on when this will be merged? I'm finding myself missing this basic functionality.
I wish all layers treated extra dimensions as batch dimensions.

Copy link

@drozzy drozzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and it works for me:

a = randn(10, 11, 12) 
b =  Dense(10, 20)
b(a) # 20x11x12

and more!

a = randn(10, 11, 15, 12) 
b =  Dense(10, 20)
b(a) # 20×11×15×12

@CarloLucibello
Copy link
Member

this is not an efficient way to do it, we should go through a reshape

@drozzy
Copy link

drozzy commented Nov 25, 2020

Yes, also I tried copying this code to my implementation and I seem to be having some issues with gpu. Don't quote me on this.

I would be happy for reshape to be merged, as long as we get something to help out with the case I provided above.
Thanks.

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

Successfully merging this pull request may close these issues.

4 participants