-
-
Notifications
You must be signed in to change notification settings - Fork 617
Refactor train! #1017
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
base: master
Are you sure you want to change the base?
Refactor train! #1017
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,13 @@ function stop() | |
| throw(StopException()) | ||
| end | ||
|
|
||
| function step!(loss, ps, minibatch, opt) | ||
| gs = gradient(ps) do | ||
| loss(minibatch...) | ||
| end | ||
| update!(opt, ps, gs) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this return incompatible with the interface proposed in #666 (comment)?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It returns |
||
| end | ||
|
|
||
| """ | ||
| train!(loss, params, data, opt; cb) | ||
|
|
||
|
|
@@ -65,10 +72,11 @@ function train!(loss, ps, data, opt; cb = () -> ()) | |
| cb = runall(cb) | ||
| @progress for d in data | ||
| try | ||
| gs = gradient(ps) do | ||
| loss(d...) | ||
| end | ||
| update!(opt, ps, gs) | ||
| # gs = gradient(ps) do | ||
| # loss(d...) | ||
| # end | ||
| # update!(opt, ps, gs) | ||
| step!(loss, ps, d, opt) | ||
| cb() | ||
| catch ex | ||
| if ex isa StopException | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this have a docstring, and be exported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it would be good to converge on its implementation, with that I'll add the doctrings and a basic test too.