Ai 2 Assg Sana 397988

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

COLLEGE OF ELECTRICAL AND MECHANICAL ENGINEERING

PARADIGMS OF AI
ASSG-2

SUBMITTED BY:
SANA NASRI
ROLL NO: 397988
MS-EE-21

SUBMITTED TO
DR NASIR RASHID
397988
SANA NASRI

Problem Statement

To program a simple neuron using Matlab for the following activation functions: -
a. Sigmoid
b. Hyperbolic Tangential
c. Signum function
d. Threshold function
The program should take input from the user to choose the activation function, number of
Neural inputs, threshold, and the associated weights

Introduction

a. Simple Neuron
It is a basic building block of Neural Network.

b. Activation functions
They are decision making units of neural networks. They calculate net output of a
neural node. To add non-linearities in the network. It allows to approx. the arbitrary
complex functions in system. It is added to the product of weights and inputs.
Following are functions.

a. Sigmoid. It squashes binary output between 0 or 1. Its in non-zero


centered.
b. TanH. It squashes between -1 and 1. Its in zero centered.

c. Signum. The signum function of a real number x is a piecewise function.

d. Threshold, A function that takes the value 1 if a specified function of the


arguments exceeds a given threshold and 0 otherwise.

c. Algorithm
function [ ] = simple_neuron( )
activation_functions = [“sigmoid” ”hyberbolic tangential” “signum function” “threshold function”];
user_input = input('Please select an activation
function: ', 's');
if any(strcmp(activation_functions,user_input))
break
end
fprintf('Invalid input. Please try again.\n');
end
num_inputs = input('Please enter the number of neural inputs: ');
threshold = input('Please enter the threshold: ');
weights = input('Please enter the weights for each input: ');
output = 0;
for i=1:num_inputs
output = output + (weights(i) * input(i));
end
output = output - threshold;
switch user_input
case 'sigmoid'
output = 1 / (1 + exp(-output));
case 'hyberbolic tangential'
output = tanh(output);
case 'signum function'
output = sign(output);
case 'threshold function'
if output >= 0
output = 1;
else
output = 0
end
end
fprintf('The output is: %d\n',output);
end

d. Results
Taking
x1 x2 x3 x4
13 11 01 13
Initializing
w1 w2 w3 w4
13 11 01 00
Threshold 0.05

a Sigmoid
b. Tanh

c. Signum
d. Threshold

You might also like