AIM: Write a program in Lisp to demonstrate working of an artificial neuron.
Post by: Sohrab Vakharia
(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.).
Source Code:
Output:
Post by: Sohrab Vakharia
(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.).
Source Code:
(defun nnFunction (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))
(print actSignlist)
(setq wghtList (rest wghtList))
(print wghtList)
)
(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 "Logistical Signal Function")
(print ( / 1 ( + 1 (exp( - 0 ( * c wghtSum))))))
(print "Threshold Exponential Signal Function")
(print ( min 1 (exp (* c wghtSum))))
)
(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))
(print actSignlist)
(setq wghtList (rest wghtList))
(print wghtList)
)
(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 "Logistical Signal Function")
(print ( / 1 ( + 1 (exp( - 0 ( * c wghtSum))))))
(print "Threshold Exponential Signal Function")
(print ( min 1 (exp (* c wghtSum))))
)
Output:
0 comments:
Confused? Feel free to ask
Post a Comment