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

Flux.testmode!() should disable gradient tracking #232

Closed
staticfloat opened this issue Apr 13, 2018 · 2 comments
Closed

Flux.testmode!() should disable gradient tracking #232

staticfloat opened this issue Apr 13, 2018 · 2 comments

Comments

@staticfloat
Copy link
Contributor

staticfloat commented Apr 13, 2018

As discussed on slack a while back, the typical Flux evaluation incantation of:

testmode!(model, true)
y_hat = mapleaves(Flux.Tracker.data, model)(feature_mat)
testmode!(model, false)

Should probably be shortened somehow. We can fold the mapleaves() call into testmode!() perhaps by having testmode!() return the baked model, and telling the user to use that new baked model instead.

@MikeInnes
Copy link
Member

You could shorten this a bit to:

predict = mapleaves(Flux.Tracker.data, model)
testmode!(predict, true)

And then you can call predict(x) wherever you need to – it also stays tied to the original model, so you can save the mapleaves call. Even the mapleaves will go away with #86 since models will be non-tracking by default.

Until then I'd be happy to have a simple out-of-place testmode function that does both things at once.

@MikeInnes
Copy link
Member

Pleasingly, with #643 this all becomes a no-op.

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

No branches or pull requests

2 participants