Neural Networks
A domain specific language for expressing neural networks using Clojure data types.
-
a Map specifies a single neuron e.g.
;; a simple neuron which sums two unit inputs (run {:phi (fn [n x] (reduce + (map * (n :weights) x))) :weights [1 1]} [1 1]) ; => 2
-
Vectors are used to represent an ordered series of neural elements
to be executed in serial
;; two neurons in serial (let [n {:phi (fn [n x] (reduce + (map * (n :weights) x)))} net [(assoc n :weights [1 1]) (assoc n :weights [2])]] (run net [1 1])) ; => 4
-
Lists are used to represent a unordered series of neural elements
to be executed in parallel.
;; a layer of three neurons in parallel followed by a single neuron (let [n {:phi (fn [n x] (reduce + (map * (n :weights) x))) :weights [2 2 2]} net [(list n n n) n]] (run net [1 1 1])) ; => 36
-
Graphs – unlike the previous data types which are built into
Clojure Graphs are specific to this library
(note: this functionality is still in development, specifically training may still be buggy)
;; three neurons connected using an arbitrary edge set (let [n {:phi (fn [n x] (reduce + (map * (n :weights) x))) :weights [2 2]} g (Graph. {:a n :b n :c n} [[:a :b] [:a :c] [:b :c]])] (run g [1 1 1])) ; [28]
Example implementations are given for the following types of neural networks.
- perceptrons
- back propagation networks
- radial basis neurons
-
self organizing maps
<iframe src="http://player.vimeo.com/video/16989946" width="400" height="300" frameborder="0"></iframe>self organizing map from Eric Schulte on Vimeo.
License
Copyright (C) 2010 Eric Schulte
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.