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 scaling of init functions #2375

Closed
wants to merge 1 commit into from
Closed

Conversation

mcabbott
Copy link
Member

@mcabbott mcabbott commented Feb 2, 2024

This allows init = 2 * randn32 to scale the initial values.

Implemented as a struct like Fix1, in order that 2 * randn32(rng) can also work.

Should probably apply to every function, and needs tests etc. But is this a good idea, first?

PR Checklist

  • Tests are added
  • Entry in NEWS.md
  • Documentation, if applicable

@ToucheSir
Copy link
Member

My inclination is that init = (args...) -> 2randn32(args...) or init = (args...) -> lmul!(2, randn32(args...)) isn't significantly more boilerplate and is a little more flexible in terms of supported operations. Perhaps documenting this pattern would be the way to go?

@darsnack
Copy link
Member

darsnack commented Feb 3, 2024

I feel the same way. A neat trick but seems like too much for something that is easily implemented as an anonymous or one line function.

@mcabbott
Copy link
Member Author

mcabbott commented Feb 5, 2024

Ok, I think I agree this is too much. Better to stay closer to Base... and if in doubt you should make the matrix yourself.

@mcabbott mcabbott closed this Feb 5, 2024
@mcabbott mcabbott deleted the init_scale branch February 5, 2024 00:02
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.

3 participants