descriptionA Neural Network DSL in Clojure
last changeWed, 24 Nov 2010 04:40:56 +0000
Content tags:

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.


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

2010-11-24 Eric Schultememoizing the neighbors function over graphsmaster
2010-11-24 Eric Schulteprints num of training points applied every second
2010-11-23 Eric Schultecaching nearest neighbor information for speedier som...
2010-11-23 Eric Schulteseems to be working using taus for time decay of sigma...
2010-11-19 Eric Schultemore options for the som-exp script, and example video...
2010-11-19 Eric Schultesom-exp script for running som experiments with a gui
2010-11-18 Eric Schultesom gui -- show training points and weights over time...
2010-11-18 Eric Schulteinitial som gui code (can draw a moving map of neurons...
2010-11-18 Eric Schulterenaming neural-net.self-organizing-maps to neural...
2010-11-18 Eric Schultewhitespace changes
2010-11-17 Eric Schulteadded self-organizing-maps to the front page
2010-11-17 Eric Schulteinitial implementation of self organizing maps
2010-11-17 Eric Schulte`neighbors' returns a vertices neighbors in a graph
2010-11-17 Eric Schulteself organizing (Kohonen) maps are on deck
2010-11-17 Eric Schulteignoring the file of raw training data
2010-11-17 Eric Schultemaximum runs option in the radial basis experiment...
3 years ago master