axon icon indicating copy to clipboard operation
axon copied to clipboard

Start weight sharing API

Open seanmor5 opened this issue 1 year ago • 1 comments

Resolves #169

Still a few API considerations/questions:

  1. Should we offer an explicit :parameters option on layer creation?
  2. How should we handle partial parameter sharing, e.g. if I just want to share the kernel of an embedding layer with a dense layer how do I express that?
  3. What kind of validations do we need in place to ensure we don't pass invalid parameters to share between layers?
  4. How do we share parameters between layers where the sharing is valid, but where the param shape function is incompatible? An example is a sharing between a dense layer and a bilinear layer. The dense layer has a parameter shape function with arity-1 for 1 input and the bilinear layer has a shape function with arity-2 for 2 inputs.
  5. What happens if we "cut-off" shared portions of the graph? I don't think the compiler will have the cache built correctly if we do in that case?

These are just the few I can think of right now. I'm sure there's more things to figure out from there. But the good news is the compiler works and the change is really simple :)

seanmor5 avatar Jul 21 '22 23:07 seanmor5

Should we offer an explicit :parameters option on layer creation?

IMO set_parameters is enough if it is not very common and we already have a get_parameters API.

How should we handle partial parameter sharing, e.g. if I just want to share the kernel of an embedding layer with a dense layer how do I express that?

Can we allow a list of keys on get_parameters(layer, keys \\ :all)? Then set_parameters can see which keys are missing.

What happens if we "cut-off" shared portions of the graph? I don't think the compiler will have the cache built correctly if we do in that case?

I think we are able to see the original part is no longer and therefore we need to look at the parameter in the "usual" position?

josevalim avatar Jul 22 '22 07:07 josevalim

Too much has changed, and this needs to be revisited with considerations from the other library

seanmor5 avatar Oct 26 '22 23:10 seanmor5