A very light layer over Java interop for working with TensorFlow.
(ns example.core
(:require [clojure-tensorflow.ops :as tf]
[clojure-tensorflow.core :as run]))
;; Define some operations
(def input (tf/constant [[0. 1.] [0. 0.] [1. 1.] [1. 0.]]))
(def weights (tf/variable (repeatedly 2 #(vector (dec (* 2 (rand)))))))
(def shallow-neural-net (tf/sigmoid (tf/matmul input weights)))
;; Run operations
(run/session-run
[(tf/global-variables-initializer)
shallow-neural-net])
The easiest option is to add [org.tensorflow/tensorflow "1.1.0-rc1"]
to your dependencies. However, TensorFlow is fastest when you use a version compiled for your hardware and OS, and this is especially true if you have a GPU.
Read the official Installing TensorFlow for Java guide for more information.
NOTE: TensorFlow requires at least Java 8 to run. This will already be the default on most machines, but if it isn't for you, it's possible to force lein to use it by adding the :java-cmd "/path/to/java" key to your
project.clj
.
Copyright © 2017 Kieran Browne
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close