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

Functional equivalents missing for some layers #2013

Open
theabhirath opened this issue Jun 29, 2022 · 3 comments
Open

Functional equivalents missing for some layers #2013

theabhirath opened this issue Jun 29, 2022 · 3 comments

Comments

@theabhirath
Copy link
Member

As things stand, only some layers in Flux have direct functional equivalents in NNlib - maxpool and meanpool do, for example, while the adaptive versions of those two layers don't. I know that they're only thin wrappers around maxpool and meanpool themselves, but would it be worth having functions that do the forward pass for these layers? While writing wrapper layers in Metalhead.jl it often feels weird to have entire Flux layers described inside of the forward pass of another layer. An example I'm working on right now is adaptive_avgmax_pool, currently written out as:

function adaptive_avgmax_pool(x, output_size = (1, 1))
    x_avg = AdaptiveMeanPool(output_size)(x)
    x_max = AdaptiveMaxPool(output_size)(x)
    return 0.5 * (x_avg + x_max)
end

While this works perfectly fine, it feels kinda odd to have a layer inside of a function which is gonna be wrapped by a layer 😅 (this may just be a side-effect of having worked with torch quite a bit so I'm not sure if this request is justified or not)

@ToucheSir
Copy link
Member

There are outstanding requests for creating/moving function-based implementations of many layers to NNlib (I should know, I created some of them!) I think everyone agrees it's a good idea, but there is a dearth of dev time to o do it.

@darsnack
Copy link
Member

The request is perfectly okay, but as an aside, isn't your example a use-case of Parallel?

@theabhirath
Copy link
Member Author

Oh, it is indeed 🤦🏽 Still adjusting to the Julian syntax v/s the Pythonic one

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

No branches or pull requests

3 participants