Skip to content
This repository has been archived by the owner on Apr 17, 2020. It is now read-only.

Latest commit

 

History

History
33 lines (21 loc) · 1001 Bytes

README.md

File metadata and controls

33 lines (21 loc) · 1001 Bytes

tfjs-cljs

A ClojureScript wrapper library for TensorFlow.js.

Usage

Add a dependency to your project.clj.

Clojars Project

Example

Clojure idiomatic rewrite of linear regression example from #getting-started.

(def model
  (-> (models/sequential)
      (models/add (layers/dense {:units 1 :inputShape [1]}))
      (models/compile {:loss "meanSquaredError" :optimizer "sgd"})))

(let [xs     (tf/tensor2d [1 2 3 4] [4 1])
      ys     (tf/tensor2d [1 3 5 7] [4 1])]
  (.then (models/fit model xs ys config {:epochs 10})
         #(tf/print (models/predict model (tf/tensor2d [5] [1 1])))))

Should I use it?

No. This library only contains a subset of TensorFlow.js to the extent of my knowledge.