Skip to content

deem0n/deep-book-clojure

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

deep-book-clojure

MXNet Clojure version of the code for the Neural Networks and Deep Learning free book

Installation

Note, that you will need to download and unzip MNIST images into the data directory. Use script from the MXNet project which I put into utils/get_mnist_data.sh, it should do the right thing. The data files are about 50Mb in size, so I didn't commit them to github.

git clone https://github.com/deem0n/deep-book-clojure.git
cd deep-book-clojure
utils/get_mnist_data.sh

Usage

lein test
lein run

Code comparasion

Python Clojure
class Network(object):

  def __init__(self, sizes):
      self.num_layers = len(sizes)
      self.sizes = sizes
      self.biases = [np.random.randn(y, 1) for y in sizes[1:]]
      self.weights = [np.random.randn(y, x) 
                      for x, y in zip(sizes[:-1], sizes[1:])]
(defrecord Network [^java.lang.Long num_layers
                  ^clojure.lang.PersistentVector sizes
                  ^clojure.lang.LazySeq biases
                  ^clojure.lang.LazySeq weights])

;Constructor
(defn make-network ([sizes]
                  (->Network
                   (count sizes)
                   sizes
                   (map #(random/normal 0 1 [% 1]) (subvec sizes 1))
                   (map #(random/normal 0 1 [%2 %1]) (butlast sizes) (subvec sizes 1)))))

JVM tuning

Someone suggested to use the following:

JVM_FLAGS="-server  \
-XX:+UseConcMarkSweepGC \
-XX:+UseCompressedOops \
-XX:+DoEscapeAnalysis \
-XX:+UseBiasedLocking \
-Xmx2g"

License

Copyright © 2019 Dmitry Dorofeev

MIT LICENSE

About

MXNet Clojure version of the code for the "Neural Networks and Deep Learning" free book

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published