anchor.diff:  ;;;; perceptron.lisp
  +(ql:quickload "split-sequence")
  +(in-package #:perceptron)
   
  -(in-package #:perceptron)
  -(ql:quickload "split-sequence")
   
   ;;; Interface code
   ;;; exemple call :  (perceptron 1 0.2 10000 100)
  
positive.code: 
    ;; Make a network of 2 layers : 784 inputs for the input layer
    ;;                              10 outputs for the output layer                       
    ;;(defparameter *network* (list (make-neuron-layer 784 hidden-neurons)
    ;;				(make-neuron-layer hidden-neurons 10)))
    (defparameter *network* (list (make-neuron-layer 784 hidden-neurons)))
  				
    (training training-set)
    (print (error-rate testing-set))
    (close *images*)
    (close *labels*))
  
  
negative.code: 
  (defun results-to-labels (results)
    ;; the number with the highest output is considered to be the right answer
    ;; TODO: low priority, probably suboptimal alogrithm but only runned once/test
    (position (reduce #'max results) results))
  
  (defun error-rate (network testing-set)
    (- 100 (* (/ (testing network testing-set) testing-set) 100.0)))
  
  (defun training (network n)
    (let ((inputs nil))
      (dotimes (x n)
        (setq inputs (next-image *images*))
        (setq network (backtracking  network
  				   inputs
  				   (network-output network inputs)
  				   (label-to-results (next-label *labels*))))))
    network)
  
  (defun testing (network n)
    (let ((success 0))
      (dotimes (x n)
        (when (equal (results-to-labels (network-output network (next-image *images*)))
  		   (next-label *labels*))
  	(setq success (+ success 1))))
      success))
  