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

outdims: possible enhancements #1253

Closed
wants to merge 2 commits into from
Closed

Conversation

hhaensel
Copy link
Contributor

@hhaensel hhaensel commented Jun 27, 2020

This PR is meant to discuss and develop further improvements to outdims as discussed in #1086

I covered @HamletWantToCode 's proposal for a fallback (still without testing) and modified the dense version to keep all dimensions, as proposed by @darsnack .

Please feel free to also contribute commits.
Good night ;-)

@CarloLucibello
Copy link
Member

CarloLucibello commented Jun 30, 2020

please rebase on master, now that #1252 is merged

@@ -64,6 +64,10 @@ outdims(c::Chain, isize) = foldr(outdims, reverse(c.layers), init = isize)
# see issue https://github.com/FluxML/Flux.jl/issues/702
# Johnny Chen -- @johnnychen94
# only slightly changed to better handle interaction with Zygote @dsweber2

# fallback
outdims(f::Function, isize::Tuple) = size(f(ones(Float32, isize..., 1)))[1:end-1] # since we aren't care about batch dimension, we are free to just set it to 1
Copy link
Member

Choose a reason for hiding this comment

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

why not leave f without type restrictions?

@DhairyaLGandhi
Copy link
Member

Bump :)

@darsnack darsnack mentioned this pull request Aug 5, 2020
4 tasks
bors bot added a commit that referenced this pull request Dec 26, 2020
1305: Updates to outdims r=CarloLucibello a=darsnack

Since #1253 stalled, I tried committing to the author's branch, but I have not received a response. So, I am creating a new PR with the following changes from the previous one:
- `outdims` for generic functions
- Size checking for `outdims(::Dense, isize)`

I also added the following additional changes
- Removed type signature restrictions on `outdims` for generic functions
- Added `outdims` for normalization layers
    - This is helpful since `BatchNorm` etc. show up in a chain or array of layers frequently when model building
    - Right now there is a method error
    - Generic functions would address this, but I think we should avoid actually evaluating the function as much as possible
- Updated docs for `outdims` changes

### PR Checklist

- [x] Tests are added
- [ ] Entry in NEWS.md
- [x] Documentation, if applicable
- [x] Final review from `@dhairyagandhi96` (for API changes).


Co-authored-by: Kyle Daruwalla <[email protected]>
Co-authored-by: lorenzoh <[email protected]>
Co-authored-by: Kyle Daruwalla <[email protected]>
bors bot added a commit that referenced this pull request Dec 26, 2020
1305: Updates to outdims r=CarloLucibello a=darsnack

Since #1253 stalled, I tried committing to the author's branch, but I have not received a response. So, I am creating a new PR with the following changes from the previous one:
- `outdims` for generic functions
- Size checking for `outdims(::Dense, isize)`

I also added the following additional changes
- Removed type signature restrictions on `outdims` for generic functions
- Added `outdims` for normalization layers
    - This is helpful since `BatchNorm` etc. show up in a chain or array of layers frequently when model building
    - Right now there is a method error
    - Generic functions would address this, but I think we should avoid actually evaluating the function as much as possible
- Updated docs for `outdims` changes

### PR Checklist

- [x] Tests are added
- [ ] Entry in NEWS.md
- [x] Documentation, if applicable
- [x] Final review from `@dhairyagandhi96` (for API changes).


Co-authored-by: Kyle Daruwalla <[email protected]>
Co-authored-by: lorenzoh <[email protected]>
Co-authored-by: Kyle Daruwalla <[email protected]>
bors bot added a commit that referenced this pull request Dec 27, 2020
1305: Updates to outdims r=CarloLucibello a=darsnack

Since #1253 stalled, I tried committing to the author's branch, but I have not received a response. So, I am creating a new PR with the following changes from the previous one:
- `outdims` for generic functions
- Size checking for `outdims(::Dense, isize)`

I also added the following additional changes
- Removed type signature restrictions on `outdims` for generic functions
- Added `outdims` for normalization layers
    - This is helpful since `BatchNorm` etc. show up in a chain or array of layers frequently when model building
    - Right now there is a method error
    - Generic functions would address this, but I think we should avoid actually evaluating the function as much as possible
- Updated docs for `outdims` changes

### PR Checklist

- [x] Tests are added
- [ ] Entry in NEWS.md
- [x] Documentation, if applicable
- [x] Final review from `@dhairyagandhi96` (for API changes).


Co-authored-by: Kyle Daruwalla <[email protected]>
Co-authored-by: lorenzoh <[email protected]>
Co-authored-by: Kyle Daruwalla <[email protected]>
bors bot added a commit that referenced this pull request Dec 30, 2020
1305: Updates to outdims r=CarloLucibello a=darsnack

Since #1253 stalled, I tried committing to the author's branch, but I have not received a response. So, I am creating a new PR with the following changes from the previous one:
- `outdims` for generic functions
- Size checking for `outdims(::Dense, isize)`

I also added the following additional changes
- Removed type signature restrictions on `outdims` for generic functions
- Added `outdims` for normalization layers
    - This is helpful since `BatchNorm` etc. show up in a chain or array of layers frequently when model building
    - Right now there is a method error
    - Generic functions would address this, but I think we should avoid actually evaluating the function as much as possible
- Updated docs for `outdims` changes

### PR Checklist

- [x] Tests are added
- [ ] Entry in NEWS.md
- [x] Documentation, if applicable
- [x] Final review from `@dhairyagandhi96` (for API changes).


Co-authored-by: Kyle Daruwalla <[email protected]>
Co-authored-by: lorenzoh <[email protected]>
Co-authored-by: Kyle Daruwalla <[email protected]>
@ToucheSir
Copy link
Member

Since we now have outputsize, I think this use-case is covered.

@darsnack
Copy link
Member

Yes, #1305 was supposed to close this.

@darsnack darsnack closed this Jun 14, 2021
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.

5 participants