Symbolics.jl icon indicating copy to clipboard operation
Symbolics.jl copied to clipboard

Add array function registration for Lux

Open SebastianM-C opened this issue 1 year ago • 3 comments

This PR adds an extension for LuxCore, where partial_apply is defined as the first(apply). This allows us to register the function as an array valued function with the size given by the dimension of the output layer.

I'm not sure how to handle the case where the parameters are form a ComponentArray. Should I make another extension (that explicitly uses ComponentArray for ps) or should I just switch the type specification for ps from ::NamedTuple to Union{NamedTuple, <:AbstractVector}?

Another thing that I'm not 100% sure of is if .out_dims is the correct way to get the output dimensions of a layer.

This needs https://github.com/LuxDL/LuxCore.jl/pull/18 first.

cc @ChrisRackauckas

SebastianM-C avatar Feb 14 '24 01:02 SebastianM-C

Last I spoke with Shashi about this, the way to do the output_size needs to be layer-dependent. So the way would be define outputsize interface in LuxCore.

Then follow up in Lux to define the outputsize for the built-in layers

avik-pal avatar Feb 14 '24 18:02 avik-pal

I saw that out_dims appears is several of the layers on https://lux.csail.mit.edu/dev/api/Lux/layers, but not all. What should be the default fallback in LuxCore for a AbstractExplicitLayer? Using .out_dims or is that a bad default?

Or should it just be

function outputsize end

?

SebastianM-C avatar Feb 14 '24 18:02 SebastianM-C

Yeah out_dims doesn't seem like a good default, since default case should work and not error out (Especially for new custom layers). Only Dense, Scale and such layers will have that field.

avik-pal avatar Feb 14 '24 19:02 avik-pal

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 76.24%. Comparing base (79c4e92) to head (d3ebacd). Report is 67 commits behind head on master.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1054      +/-   ##
==========================================
- Coverage   77.07%   76.24%   -0.84%     
==========================================
  Files          32       33       +1     
  Lines        3533     3586      +53     
==========================================
+ Hits         2723     2734      +11     
- Misses        810      852      +42     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Mar 03 '24 13:03 codecov-commenter

Ok, going to take a look at using this in neural pde soon, could i please get some clarification on how this is supposed to be used?

xtalax avatar Mar 14 '24 14:03 xtalax