Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun randlist (n)
- (let ((lst ()))
- (dotimes (i n)
- (setf lst (cons (- (/ (random 101) 100) 50) lst)))
- lst))
- (defun scalar-product (v1 v2)
- (if (null v1)
- 0
- (+ (* (first v1) (first v2))
- (scalar-product (rest v1) (rest v2)))))
- (defun neuron(weights inputs)
- (tanh (scalar-product weights inputs)))
- (defun layer(neurons)
- (let
- (
- (weights (first(first neurons)))
- (inputs (second(first neurons))))
- (print weights)
- (print inputs)
- (if(null neurons)
- ()
- (
- (
- (neuron weights inputs)
- (layer(rest neurons)))))))
- ;(print (neuron '(0 1 -1) '(-0.3 0.7 -0.2)))
- (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