Guest User

Untitled

a guest
Apr 2nd, 2013
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.73 KB | None | 0 0
  1. (defun randlist (n)
  2.   (let ((lst ()))
  3.     (dotimes (i n)
  4.       (setf lst (cons (- (/ (random 101) 100) 50) lst)))
  5.     lst))
  6.  
  7. (defun scalar-product (v1 v2)
  8.   (if (null v1)
  9.     0
  10.     (+ (* (first v1) (first v2))
  11.       (scalar-product (rest v1) (rest v2)))))
  12.  
  13. (defun neuron(weights inputs)
  14.   (tanh (scalar-product weights inputs)))
  15.  
  16. (defun layer(neurons)
  17.   (let
  18.     (
  19.       (weights (first(first neurons)))
  20.       (inputs  (second(first neurons))))
  21.     (print weights)
  22.     (print inputs)
  23.     (if(null neurons)
  24.       ()
  25.       (
  26.         (
  27.           (neuron weights inputs)
  28.           (layer(rest neurons)))))))
  29.  
  30. ;(print (neuron '(0 1 -1) '(-0.3 0.7 -0.2)))
  31. (print (layer '(((0 1 -1) (-0.3 0.7 -0.2)) ((0 1 -1) (-0.3 0.7 -0.2)))))
Advertisement
Add Comment
Please, Sign In to add comment