-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
Support all output types in reverse-mode #169
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #169 +/- ##
==========================================
- Coverage 87.68% 87.57% -0.12%
==========================================
Files 99 100 +1
Lines 15792 15796 +4
Branches 850 850
==========================================
- Hits 13847 13833 -14
- Misses 1095 1113 +18
Partials 850 850 ☔ View full report in Codecov by Sentry. |
Qs for @littleredcomputer:
Looking forward to your feedback here... |
src/emmy/calculus/derivative.cljc
Outdated
MultiFn | ||
(perturbed? [_] false) | ||
(replace-tag [f old new] (replace-tag-fn f old new)) | ||
(extract-tangent [f tag] (extract-tangent-fn f tag)) | ||
(extract-tangent [f tag mode] (extract-tangent-fn f tag mode)) | ||
(extract-id [f id] (comp #(d/extract-id % id) f)) |
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.
it's kind of an fmap
for most types... after your multimethod conversion, @littleredcomputer , do you feel like these should be multimethods too? Then we could have a ::functor
type that supports fmap?
|
||
(extract-id [this id])) | ||
|
||
(defrecord Completed [v->partial] |
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.
annoying that this now has to live in differential
. It has to be here so that a Dual
can return the correct default type if it's called with a different tag.
[IObj | ||
(meta [_] m) | ||
(withMeta [_ meta] (Series. xs meta)) | ||
(:clj |
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.
formatting change that snuck in
@@ -142,7 +140,12 @@ | |||
;; This implementation is called if a tape ever makes it out of | |||
;; forward-mode-differentiated function. If this happens, a [[TapeCell]] |
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.
TODO update the docs here. We need a better narrative now that hints at reverse-mode in the differential.cljc
exposition.
test/emmy/tape_test.cljc
Outdated
@@ -220,10 +220,11 @@ | |||
|
|||
(checking "d/extract-tangent" 100 [tag gen/nat | |||
tape (sg/tapecell gen/symbol)] | |||
(is (zero? (d/extract-tangent tape tag)) | |||
;; TODO fix these for non-dual |
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.
TODO add a test for the case where we pass a different mode
8de774d
to
0ee0d6d
Compare
This PR:
mode
argument toemmy.differential/extract-tangent
, allowing us to use this for reverse mode instead ofemmy.tape/->partials
(which is now gone)emmy.tape/extract
withemmy.differential/extract-id
, now part of theIPerturbed
protocol.We need these two passes because:
Completed
maps ofnode => sensitivity
.