scittle

Matthew Downey 2023-06-03T16:37:37.514919Z

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.

👍 3
👍🏼 1
🆒 4
😍 10
bherrmann 2023-06-26T21:31:22.536529Z

Wow that is cool!

borkdude 2023-06-03T18:20:59.506599Z

Pretty cool! If you haven't already, share the article in #news-and-articles

❤️ 1
Daniel Slutsky 2023-06-03T20:52:28.103589Z

Wonderful!! It may be worth exploring in combination with @chris441'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.

john 2023-06-03T21:17:44.921549Z

This is amazing @matthewdowney20!

john 2023-06-03T21:18:54.110689Z

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))

john 2023-06-03T21:20:47.113259Z

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

john 2023-06-03T21:27:36.764749Z

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

john 2023-06-03T21:29:05.294609Z

I kid, I kid

james 2023-06-04T07:41:59.384029Z

And amazingly it works in the browser on android if you tap the individual pixels. It seems to default to 8 for a single pixel.

john 2023-06-04T07:50:21.124309Z

Yeah, and that's an interpreted in scittle. Such a rad demo

Matthew Downey 2023-06-04T15:32:10.977119Z

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

Matthew Downey 2023-06-04T15:34:20.810199Z

thanks @john! 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

➕ 1
Matthew Downey 2023-06-04T15:35:48.981209Z

@james427 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

john 2023-06-05T04:19:15.333379Z

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