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

Remove usage of global variables in linear and logistic regression tutorial training functions #2537

Merged
merged 8 commits into from
Dec 4, 2024

Conversation

christiangnrd
Copy link
Contributor

@christiangnrd christiangnrd commented Dec 4, 2024

Based off Slack "thread".

I think we should bikeshed the following:

  1. Do we rename all local function variables to be different from a global variable? If so, what should they be.
  2. Add return statements to the functions to make it clear what is meant to be returned. Or just a return to make it clear that no output is expected from the train_<something>!() functions.

Personally, I think we should definitely do 1., and probably do 2.

@mcabbott
Copy link
Member

mcabbott commented Dec 4, 2024

Thanks!

I'm in favour of 1, as I remember this being confusing. What the names should be I don't know, as having too many names for the same thing also gets messy. Probably _W, _b, _x, _y are too far from plain text? Are WW, bb, xx, yy too ugly? W_local, b_local, ... too long although maybe the first time?

Not sure about 2. It's a bit weird to put return in when it's optional. Maybe my vote would be none (as it is now) but perhaps a # this value is returned on the first function whose return value we do want?

@christiangnrd
Copy link
Contributor Author

What about weights, biases, data, targets? Long but for a tutorial I feel like clarity is more important.

@mcabbott
Copy link
Member

mcabbott commented Dec 4, 2024

I'm not so worried about length, as about obscuring the relation between the locals and the globals.

One idea is to call globals full words like weights, biases, data, targets, and corresponding locals shortened versions like wei, bias, dat, targ? Too ugly? (Some word choices work better for this than others.) Maybe w, b, d, t as locals still preserves the link?

@christiangnrd
Copy link
Contributor Author

christiangnrd commented Dec 4, 2024

One idea is to call globals full words like weights, biases, data, targets, and corresponding locals shortened versions like wei, bias, dat, targ? Too ugly? (Some word choices work better for this than others.) Maybe w, b, d, t as locals still preserves the link?

I agreed with you until I started making the changes and realized that the globals are named that way to match with the mathematical definitions from the tutorial, so I think they should remain as-is and we change the custom training function arguments to be a slightly more verbose term that aligns with their definition.

Coming from a CS background, seeing that W is passing into a function as the weights argument would help me remember what W represents.

See my latest commit and let me know what you think.

Copy link
Member

@mcabbott mcabbott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, good point about matching the equations. Then this is fine, I think.

@CarloLucibello CarloLucibello merged commit 281f8c9 into FluxML:master Dec 4, 2024
5 of 9 checks passed
@mcabbott
Copy link
Member

mcabbott commented Dec 4, 2024

Documentation CI was failing here for other reasons, but once fixed, this tutorial now produces a failure:

Screenshot 2024-12-04 at 14 35 36

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

Successfully merging this pull request may close these issues.

3 participants