Fork me on GitHub
#scittle
<
2023-06-03
>
Matthew Downey16:06:37

I used Scittle to embed this little digit recognition widget in https://matthewdowney.github.io/clojure-neural-networks-from-scratch-mnist I wrote up with some notes on getting started with neural nets. Very convenient to do this using Scittle instead of a whole cljs project because it was < 100 loc.

👍 5
😍 18
🆒 7
2
borkdude18:06:59

Pretty cool! If you haven't already, share the article in #C8NUSGWG6

❤️ 1
Daniel Slutsky20:06:28

Wonderful!! It may be worth exploring in combination with @UDRJMEFSN's https://github.com/cnuernber/tmdjs (DataFrame and Numerics for ClojureScript). tmdjs does seem to work well with Scittle (currently this is supported by the https://github.com/scicloj/scittle, but should be also doable in the original Scittle itself using the new https://clojurians.slack.com/archives/C034FQN490E/p1683142333100929?thread_ts=1682156428.196199&amp;cid=C034FQN490E). I'd be happy to help exploring that.

john21:06:44

This is amazing @UP7RM6935!

john21:06:54

Didn't realize mnist could be reduced down to:

(defn sigmoid [n] (/ 1.0 (+ 1.0 (Math/exp (- n)))))
  
  (defn feedforward [inputs weights biases]
    (for [[b ws :as _neuron] (map vector biases weights)]
      (let [weighted-input (reduce + (map * inputs ws))]
        (sigmoid (+ b weighted-input)))))
  
  (defn argmax [numbers]
    (let [idx+val (map-indexed vector numbers)]
      (first (apply max-key second idx+val))))
  
  (defn digit [pixels]
    (-> pixels (feedforward w0 b0) (feedforward w1 b1) argmax))

john21:06:47

That's what I love about clojure/lisp though. Implementing a solution in Clojure makes the whole problem easier for me to understand. Thanks for putting this together

john21:06:36

> OpenAI: Hey there son, you gotta license for those there sufficiently powerful Clojure functions?

john21:06:05

I kid, I kid

Matthew Downey15:06:10

@U066L8B18 cool, tmdjs looks like a lifesaver for tackling "real" data tasks in JS

Matthew Downey15:06:20

thanks @U050PJ2EU! i was also surprised by how concise the inference could be. a friend showed me his c# implementation and i was like, oh, this seems like something i could actually figure out, at least at a basic level, without reading a whole textbook haha

2
Matthew Downey15:06:48

@U9G5NDV4Y haha yeah it's a bit of a hack, i gave up on mobile after a few attempts to make the https://github.com/matthewdowney/clojure-neural-networks-from-scratch/blob/main/mnist-scittle/canvas.js file handle the mobile touch / move events

john04:06:15

I'm curious about changing this into a text completion API, for like an omnibox with NLP completion over a narrow domain, and have it running right in the browser

bherrmann21:06:22

Wow that is cool!