themetaschemer / malt

Machine Learning Toolkit accompanying The Little Learner by Daniel P. Friedman and Anurag Mendhekar
MIT License
212 stars 25 forks source link

`random-tensor` doesn't work well with overridden operator provided in the same package. #17

Closed yangchenyun closed 1 year ago

yangchenyun commented 1 year ago

In chapter 13, frame 60, where random-tensor is defined, the s-expression doesn't work out of the box:

#lang racket
(require malt)
;; (random-tensor 0.0 (/ 1.0 2.0) '(6 4)) ;; => would fail
(random-tensor 0.0 0.5 '(6 4))

It might be due to the / used here has been overridden by the malt package and random-tensor:

#lang racket
(require malt)
(random-tensor 0.0 (ρ (/ 1.0 2.0)) '(6 4)) ;; => works

From interlude I onwards, the reader would expect all primitive operators to be their extended version, so the print in the textbook in frame 60 lacks the context; from a library user's perspective, one would expect random-tensor to hide the inner workings of extended functions here as well.

themetaschemer commented 1 year ago

Thanks for reporting. Fixed in 0e1c2c5