-
Hi everyone! I am not a schemer but i am trying to implement the code in the book in another lisp (common lisp) so i think my problem could be related to the language and not to implemented procedures. I am stuck to this code for dualized nested tensor (a dual where the real part is a tensor) : (define d*-1-1
(ext2 d* 1 1))
(define d*-2-1
(ext2 d*-1-1 2 1)) given the definition of (define ext2
(λ (f m n)
(prim2
(ext2-ρ (ρ-function f) m n)
(ext2-∇ (∇-function f) m n)))) and define ρ-function
(λ (f) (f ρ-function))) I expect an expansion, for (ext2-ρ (ρ-function d*-1-1) m n)
(ext2-ρ (d*-1-1 ρ-function) m n) But shouldn't be I suspect that the issue could be related to my implementation of (defun rho-function (f)
(funcall f :rho-function) But not so sure; moreover I have to add that I am converting the tests too and, for dualized nested tensors all the tests for scalar-ops and comparators passes. I hope I has been able to explain my issue in a clear way. If not, sorry I am a bit confused by this code, I mean, more than usual! 😄 Any help is appreciated, many thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Hi! I think i have found the reason for my mistake: the function https://github.com/themetaschemer/malt/blob/main/nested-tensors/autodiff/B-prims.rkt#L30 and the same will be true for https://github.com/themetaschemer/malt/blob/main/nested-tensors/ext-ops/A-scalar-ops.rkt#L83 In my code i was forcing these functions to take only two parameters and this change leads to the error. I hope this thread could help same other person, by the way! Bye! |
Beta Was this translation helpful? Give feedback.
-
Hi Cage, I'm glad you were able to resolve it. But if you're doing this in CL, you might be able to use funcallable instances to implement prim1 and prim2 as well since the rho-function and nabla-function are "fields" of the primitive. |
Beta Was this translation helpful? Give feedback.
-
Hi @cage2 ! I am trying to use the CLOS where I can in my code (for example I have written But your suggestion encourage me to try to start to grasp it with funcallable instances, seems a not impossible task to accomplish. Anyway let me add that the book is just wonderful. I have learnt so many things with the "little..." book series and this one is not an exception! Thanks! Bye! |
Beta Was this translation helpful? Give feedback.
Hi!
I think i have found the reason for my mistake: the function
prim2
returns a function that accepts an arbitrary number of argument:https://github.com/themetaschemer/malt/blob/main/nested-tensors/autodiff/B-prims.rkt#L30
and the same will be true for
d-1-1
(see the definition above) andd*
https://github.com/themetaschemer/malt/blob/main/nested-tensors/ext-ops/A-scalar-ops.rkt#L83
In my code i was forcing these functions to take only two parameters and this change leads to the error.
I hope this thread could help same other person, by the way!
Bye!
C.