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:          errors))
  
  (defun backtracking-neuron (neuron input-values error)
    (let ((pdaf (pdaf (weighted-sum neuron input-values))))
      (map 'vector
           (lambda (weight input-value) (+ weight
  					 (delta-weight pdaf input-value error)))
  	 neuron
  	 input-values)))
  				   
  (defun compute-error (network-outputs expected-outputs)
    (map 'vector
         #'-
         network-outputs
         expected-outputs))
  
  (defun delta-weight (pdaf input-value error)
    (* -1 *learning-rate* error pdaf input-value))
    
  (defun pdaf (weighted-sum)
    ;; partial derivative of the activation function
  
negative.code:   ;; Using logistic function
    (/ 1 (+ 1 (exp (* -1 weighted-sum)))))
  
  (defun output-error (output-values expected-values)
    (list(map 'vector
         #'-
         output-values
         expected-values)))
    
  ;;; Network : list of layers
  ;;; Layer : vector of neurons
  ;;; Neuron : vector of weights
  
  ;;; Backtracking
  (defun backtracking (network input-values output-values expected-values)
    (map 'vector
         #'(lambda (layer error-network)
  	   (map 'vector #'(lambda (neuron error-layer)
  			       (map 'vector #'(lambda (weight input-value error-neuron)
  						(+ weight (* -1
  						             *learning-rate*
  						             error-neuron
  						             input-value)))
  				    neuron
  				    input-values
  				    error-layer))
  		     layer
  		     error-network))
  	  network
  	  (backtracking-network network
  				input-values
  				(output-error output-values expected-values))))))
  
  (defun backtracking-network (network input-values errors)
    (let ((backtracking (backtracking-layer (car network)
  					  input-values
  					  (car errors))))
      (if (cadr network)
        (push (backtracking-network (cdr network)
  				  (layer-output (car network)
  					        input-values)
  				  backtracking)
  	    backtracking)
        (list backtracking))))
        
  
  
  
  (defun backtracking-layer (layer input-values errors)
    (print errors)
      (map 'vector
  	 (lambda (neuron error) (backtracking-neuron neuron
  						     input-values
  