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

Allow passing kwargs to the layers in the Sequential layer #653

Closed
Artur-Galstyan opened this issue Feb 5, 2024 · 4 comments
Closed

Allow passing kwargs to the layers in the Sequential layer #653

Artur-Galstyan opened this issue Feb 5, 2024 · 4 comments

Comments

@Artur-Galstyan
Copy link
Contributor

Artur-Galstyan commented Feb 5, 2024

Hi there,

I had just noticed that I cannot pass any parameters to the layers defined in the Sequential layer - except for x, state, and key. If the layers within Sequential require additional parameters, then you're out of luck, because x is defined as Array (as opposed to tuple[Any] (e.g.))

I created a simple PR for this, see #652

@patrick-kidger
Copy link
Owner

Thanks!
What's the use-case? Right now I'm tempted to suggest that if you need this, then to just write things out directly. Sequential is really only designed for simple models.

@Artur-Galstyan
Copy link
Contributor Author

Artur-Galstyan commented Feb 5, 2024

Concretely, I need this for my Transformer. See line 191

Each Block call takes a mask as input (because it has a MHA). The Transformer has a Sequential with n Block elements. Each Block should get the same mask. Therefore, I want to pass those to each Block.

I don't think we lose anything here and don't make it more complicated. It's up to the user - if there are no kwargs, then simply don't use them, but the option is there if you need to 🙂

I should also mention that the solution is not to change the signature to tuple[any] but rather to allow for kwargs and simply forward those kwargs to each module within Sequential.

@patrick-kidger
Copy link
Owner

Hmm, I agree it's not too much more. But also just writing out the for loop manually isn't too tricky either. (In fact if I was to go back and do Equinox again, I'd probably leave out Sequential altogether!)

So on that basis I think I'm probably going to suggest keeping things simple and not implementing this, I'm afraid! :)

@Artur-Galstyan
Copy link
Contributor Author

Artur-Galstyan commented Feb 5, 2024

Ok 🥲 I'll close the PR and this issue then.

@Artur-Galstyan Artur-Galstyan closed this as not planned Won't fix, can't repro, duplicate, stale Feb 5, 2024
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

No branches or pull requests

2 participants