logistic, threshold, hyperbolic-tangent, linear, exponential, sigmoid functions
Write a program in Lisp to demonstrate working of an artificial
neuron.
(Enter an input vector X and weight vector W. Calculate weighted
sum XW. Transform this using signal or
activation functions like logistic,threshold, hyperbolic-tangent, linear, exponential,
sigmoid etc and display the output.)
(defun nnFunctions (actSignList
wghtList c n)
(setq wghtSum 0)
(setq resFunc 0)
(loop
(when
(equal (first actSignList) nil) (return))
(setq
wghtSum (+ wghtSum (* (first actSignList) (first wghtList))))
(print
wghtSum )
(setq
actSignList (rest actSignList))
(setq
wghtList (rest wghtList))
)
(print
"Logistical Signal Function")
(print
(/ 1 (+ 1 (exp (- 0 (* c wghtSum))))))
(print
"Hyperbolic tangent Signal Function")
(print
(tan (* 10 wghtSum)))
(print
"Threshold Linear Signal Function")
(if
(<= 1 (* c wghtSum)) (print 1) (print 0))
(print
"Linear Signal Function")
(print
(* c wghtSum))
(print
"Threshold Exponential Signal Function")
(print
(min 1 (exp (* c wghtSum))))
(print
"Threshold Distribution Signal Function")
(print
(max 0 (- 1 (exp (- 0 (* c wghtSum))))))
(print
"Ratio Polynomial Signal Function")
(print
(max 0 (/ (expt wghtSum n) (+ c (expt wghtSum n)))))
)
(nnFunctions '(1 2 3) '(2 3 4) 5 4 )
OUTPUT:
---- Done ----
0
---- Done ----
2
8
20
"Logistical Signal
Function"
1.0
"Hyperbolic tangent Signal
Function"
-1.7925274837903817
"Threshold Linear Signal
Function"
1
"Linear Signal Function"
100
"Threshold Exponential Signal
Function"
1
"Threshold Distribution Signal
Function"
1.0
"Ratio Polynomial Signal
Function"
32000/32001
32000/32001
0 comments: