SC_Module1_Notes
SC_Module1_Notes
MODULE 1
INTRODUCTION TO SOFT COMPUTING
●
It refers to a group of computational techniques that are based
on Artificial intelligence (AI) and natural selection.
●
It provides cost-effective solutions to the complex real-life
problems for which hard computing (conventional ) solution
does not exist.
●
The objective of soft computing is to provide precise
approximation and quick solutions for complex real-life
problems.
Hard computing :
●
Hard computing uses traditional mathematical methods to solve problems, such as algorithms and
mathematical models.
●
Deals with precise models where accurate solutions are achieved quickly
Soft computing:
●
Deals with approximate models and gives solutions to complex problems
●
Soft computing uses techniques such as fuzzy logic, neural networks, genetic algorithms, and other
heuristic methods to solve problems.
● Is ideal for solving problems that are difficult or impossible to solve exactly
Characteristics of Soft computing
●
Soft computing provides an approximate but precise solution for real-life problems.
●
The algorithms of soft computing are adaptive, so the current process is not affected by
any kind of change in the environment.
●
The concept of soft computing is based on learning from experimental data.
●
It means that soft computing does not require any mathematical model to solve the
problem.
●
Soft computing helps users to solve real-world problems by providing approximate results
that conventional and analytical models cannot solve.
●
It is based on Fuzzy logic, genetic algorithms, machine learning, ANN, and expert
systems.
DIFFERENCE BETWEEN SOFT COMPUTING & HARD
COMPUTING
APPLICATIONS OF SOFT COMPUTING
1. Home Appliances :
●
Refrigerators, microwaves, washing machines, etc. are becoming smart because of artificial
intelligence, machine learning, and fuzzy logic.
●
Not only can they communicate with the users about their usage, but they can also adjust
their settings according to the workload at that very moment.
2. Transportation
●
Right from the production of cars in the factory to be on the road for navigation, traffic
prediction, and diagnostics of the car, fuzzy logic and evolutionary computing are widely used.
●
Fuzzy logic techniques are used in engine control, automatic transmissions, antiskid steering,
etc.
3. Healthcare
●
To diagnose the patients’ ailments from the symptoms accurately and hence save on
money and side effects from medications of the wrong diagnosis.
●
Early diagnosis of critical diseases has also helped save numerous lives which
otherwise would have been lost.
4. Investment and Trading
●
The data present in the finance field is in opulence and traditional computing is not
able to handle and process that kind of data.
●
There are various approaches done through soft computing techniques that help to
handle noisy data.
●
Pattern recognition technique is used to analyze the pattern or behavior of the data
and time series is used to predict future trading points.
5. Image Processing using Soft Computing
●
It is a high-level processing technique which includes recognition of patterns.
●
Using soft computing solves the problem of computational complexity and efficiency in the
classification.
●
These algorithms give the fastest solutions to pattern recognition.
●
Help in analyzing the medical images obtained from microscopes as well as examine the X-
rays.
6. Handwritten Script Recognition
●
It can translate multilingual documents and sort the various scripts accordingly.
●
It uses the concept of “block-level technique” where the system recognizes the particular
script from a number of script documents given.
7. Soft Computing Techniques in Power System Analysis
●
Soft computing uses the method of Artificial Neural Network (ANN) to predict any
instability in the voltage of the power system.
●
Using the ANN, the pending voltage instability can be predicted. The methods which are
deployed here, are very low in cost.
BNN
●
Dendrites : The first two neuronal functions, receiving and processing incoming
information, generally take place in the dendrites and cell body.
●
Axons : Axons are covered with a special insulating substance called myelin, which
helps them convey the nerve impulse rapidly.
●
Synapses : Connections, known as synapses, are the sites at which information is
carried from the first neuron, the presynaptic neuron, to the target neuron (the
postsynaptic neuron)
Structure of ANN
●
Inputs :x1 and x2
●
Input neurons : X1 and X2 which bufferes the input.
●
Output : y
●
Output neurons : Y which is the computational layer that generates output y.
●
Weights are associated with the connection link that indicates how much influence
that particular input will have on output
ANN Vs BNN
ANN BNN
Definition It is the mathematical model which is mainly It is also composed of several processing pieces
inspired by the biological neuron system in the known as neurons that are linked together via
human brain. synapses.
Processing Its processing was sequential and centralized. It processes the information in a parallel and
distributive manner.
Size It is small in size. It is large in size.
Complexity It cannot perform complex pattern recognition. The large quantity and complexity of the connections
allow the brain to perform complicated tasks
Operating Its operating environment is well-defined and Its operating environment is poorly defined and
Environment well-constrained unconstrained.
Response time Its response time is measured in nanoseconds Its response time is measured in milliseconds.
Rate It processes the information at a faster speed. It processes the information at a slow speed.
●
The model of an artificial neural network can be
specified by three entities:
– Interconnections
– Activation functions
– Learning rules
Interconnections:
●
Interconnection can be defined as the way in which the processing elements (Neuron) in ANN
are connected to each other.
●
These arrangements always have two layers that are common to all network architectures, the
Input layer and output layer where the input layer buffers the input signal, and the output layer
generates the output of the network.
●
The third layer is the Hidden layer, in which neurons are neither kept in the input layer nor in
the output layer.
●
These neurons are hidden from the people who are interfacing with the system and act as a black
box to them.
●
By increasing the hidden layers with neurons, the system’s computational and processing power
can be increased but the training phenomena of the system get more complex at the same time.
Types of Connections :
a. Single layer feedforward network
●
Only two layers a). Input layer b). Output layer
●
But the input layer does not count because no computation is performed in this layer.
●
The output layer is formed when different weights are applied to input nodes and the
cumulative effect per node is taken.
●
After this, the neurons collectively give the output layer to compute the output signals.
b. Multilayer feed-forward network
●
Has a hidden layer that is internal to the network .
●
Each node in one layer will be connected to all the nodes in the next
layer.
●
Information flow through the input function, and the intermediate
computations are used to determine the output Z.
●
There are no feedback connections in which outputs of the model are
fed back into itself.
c. Single node with its own feedback
●
When outputs can be directed back as inputs to the same layer
or preceding layer nodes, then it results in feedback networks.
●
Recurrent networks are feedback networks with closed loops.
●
Figure shows a single recurrent network having a single
neuron with feedback to itself.
d. Single-layer recurrent network
●
The above network is a single-layer network with a feedback connection in which the
processing element’s output can be directed back to itself or to another processing element or
both
●
Unlike feedforward neural networks, RNNs can use their internal state (memory) to process
sequences of inputs.
e. Multilayer recurrent network
●
In this type of network, processing element output can be directed to the processing element
in the same layer and in the preceding layer forming a multilayer recurrent network.
●
They perform the same task for every element of a sequence, with the output being dependent
on the previous computations.
●
Inputs are not needed at each time step.
●
The main feature of a Recurrent Neural Network is its hidden state, which captures some
information about a sequence.
2.Learning
●
It is the process by which a nn adapt itself to an environment by making proper
parameter adjustment, resulting in the production of desired response.
Types of learning
a). Supervised :
●
Done under the supervision of a teacher.
●
This learning process is dependent.
●
The input vector is presented to the network, which will give an output vector.
●
This output vector is compared with the desired output vector.
● An error signal is generated, if there is a difference between the actual output and the
desired output vector.
●
On the basis of this error signal, the weights are adjusted until the actual output is
matched with the desired output.
b). Unsupervised :
●
Done without the supervision of a teacher.
●
This learning process is independent.
●
During the training of ANN under unsupervised learning, the input vectors of similar type are grouped without the
use of training data.
●
In the training process, the network receives the input patterns and organizes these patterns to form clusters.
●
When a new input pattern is applied, then the neural network gives an output response indicating the class to which
the input pattern belongs.
●
There is no feedback from the environment as to what should be the desired output and if it is correct or incorrect.
●
Hence, in this type of learning, the network itself must discover the patterns and features from the input data, and the
relation for the input data over the output. (eg :raining/hot temp so no cricket, student studies by looking into prev.yr qp)
●
If for an input, a pattern class cant be found, then a new class is generated.
c). Reinforcement Learning
●
As the name suggests, this type of learning is used to reinforce or strengthen the network over some critic
information.
●
This learning process is similar to supervised learning, however we might have very less information.for eg:
the n/w might be told that its actual o/p is only ‘50% correct’.
●
During the training of network under reinforcement learning, the network receives some feedback from the
environment.
●
This makes it somewhat similar to supervised learning.
●
However, the feedback obtained here is evaluative not instructive, which means there is no teacher as in
supervised learning.
●
After receiving the feedback, the network performs adjustments of the weights to get better critic
information in future.
Criteria Supervised ML Unsupervised ML Reinforcement ML
Definition Learns by using Trained using Works on interacting
labelled data unlabelled data without with the environment
any guidance.
Type of data Labelled data Unlabelled data No – predefined data
●
where k or λ = steepness or slope parameter, By varying the value of k, sigmoid function with
different slopes can be obtained.
●
It has a range of (0,1).
●
b. Bipolar sigmoidal function −
●
It has a range of (-1,1).
●
It can be positive or negative in nature.
●
It is always bounded, which means its output cannot be less than -1 and more than
1.
●
It is also strictly increasing in nature like sigmoid function.
●
It can be defined as
5. Ramp function
●
y=f(yin) = 1, if yin>1
yin, if 0<=yin<= 1
0, if yin<0
QUESTIONS
●
Bias is an additional parameter in the Neural Network which is used to adjust the output
along with the weighted sum of the inputs to the neuron.
●
Therefore Bias is a constant which helps the model in a way that it can fit best for the given
data.
TUTORIAL 1
●
a).
TUTORIAL 1
●
b).
McCulloch-Pitts Model of Neuron (MP Neuron)
●
Oldest model
●
The model has two layers :
1. Input layer
2. Output layer
●
The model has only two types of inputs :
1. Excitatory : nodes whose weights are positive
2. Inhibitory : nodes whose weights are negative
●
The inputs of the McCulloch-Pitts neuron could be either 0 or 1.
●
Activation of a mp neuron is binary
1 -> fired
0 ->not fired
●
It has a threshold function as an activation function.
●
Threshold plays a major role in mp neuron
●
Since the firing of the output neuron is based upon the threshold, the activation function here is
defined as
yout = f(yin) = 1 , if yin >= θ
0, if yin < θ
●
So, the output signal yout is 1 if yin is greater than or equal to a given threshold value θ, else 0.
●
Threshold value should satisfy the following condition
θ ≥ nw – p
where,
n = no. of neurons in i/p layer
w = no. of positive weights
p = no of negative weights
QUESTION 1 : Implement OR function using MP
Step 1: Draw the truth table
●
So, the neuron should fire only on (x1,x2 ) = (1,0), (0,1) or (1,1)
●
If θ = 1, neuron will fire for (1,0), (0,1) or (1,1). Y
●
Therefore , θ = 1.
●
θ=1, W1=1, w2=1 x2 w2=1
●
Final implementation is : x2
QUESTION 2 : Implement AND function using MP
neuron
Step 1: Draw truth table of AND x1 X1 w1 y
Y
x2 X2 w2
Step 4: Find a threshold value θ such that, neuron will fire only when x1=1 and x2=1.
●
For this input case, we have obtained net input yin as 2.
●
Hence, based on this net input, the threshold is set, i.e. if the threshold value is greater than or
equal to 2, then the neuron fires, else it does not fire.
●
So the threshold value is set to 2. ie, (θ= 2).
Short cut method : θ should satisfy the condition θ >= nw- p
Where, n = no.of inputs
w = positive weights
p = negative weights
●
Here, n = 2, w = 1 (excitatory weights) and p = 0 (no inhibitory weights).
●
Substituting these values in the above equation we get
θ ≥ nw-p
θ ≥ (2*1)-0
θ≥2
●
Thus, the output of neuron Y can be written as :
●
Thus, for w1=1, w2=1 and θ =2, the neuron will fire only for (x1,x2)=(1,1).
●
Final implementation is
QUESTION 3: Implement NOR function using MP
QUESTION 4: Implement XOR function using MP
Step 1: Draw truth table for XOR function
Step 2: In this case, the output is "ON" for only odd number of 1's. For the rest, it is "OFF."
XOR function cannot be presented by simple and single logic function; it is represented as
x1 w11
X1 Z1 v1
w12 y
Y
w21
x2 w22 v2
X2 Z2
●
A single-layer net is not sufficient to represent the function. An intermediate layer is
necessary.
●
x1 w11
X1 Z1
x2 w21
X2
θ=1
x1 X1
w12
x2
x2 w22 Z2
(1,1),z2in = 1 x -1 + 1 x 1 = 0
●
Based on this, w12=-1 and w22=1, θ=1 for the z2 neuron
Consider 3rd function, y=z1 OR z2
z1
z1
v1
y
Y
z2 v2
z22
●
Setting a threshold of θ = 1, v1=v2= 1, which implies that the net is recognized.
Therefore, the analysis is made for XOR function using M-P neurons.
●
Thus for XOR function, the weights are obtained as
●
Neural net for XOR function :->
Tutorial 2
QUESTION : Implement NAND gate function using
MP neuron model with binary input
Q: Implement ANDNOT function using McCulloch-Pitts neuron(use binary
representation)
●
In the case of ANDNOT function, the response is true, if the first input is true and the second input is false.
●
For all other input variations, the response is false.
●
Step 1: Draw the truth table for ANDNOT Function.
●
From the calculated net inputs, it is not possible to fire the neuron for input (1, 0) only. Hence, these weights are not
suitable
●
Assume one weight as excitatory and the other as inhibitory, i.e.,w1 =1, w2=-1
HEBB NETWORK
●
Hebb or Hebbian learning rule comes under Artificial Neural Network (ANN)
which is an architecture of a large number of interconnected elements called
neurons.
●
These neurons process the input received to give the desired output.
●
The nodes or neurons are linked by inputs (x1,x2,x3…xn), connection weights
(w1,w2,w3…wn), and activation functions (a function that defines the output of
a node).
●
The weight update in the Hebb rule is given by;
ith value of w(new) = ith value of w(old) + (ith value of x * y)
●
STEP 1: Initialize the weights and bias to ‘0’ i.e w1=0,w2=0, .…, wn=0.
●
STEP 2: Steps 2–4 have to be performed for each input training vector and
target output pair i.e. s:t (s=training input vector, t=training output vector)
●
STEP 3: Input units activation are set and in most of the cases is an
identity function(one of the types of an activation function) for the input
layer;
ith value of x = ith value of s for i=1 to n
Identity Function:It is a linear function and defined as f(x)=x for all x
●
STEP 4: Output units activations are set y:t
●
STEP 5: Weight adjustments and bias adjustments are performed;
1. ith value of w(new) = ith value of w(old) + ((ith value of x) * y)
2. new bias(value) = old bias(value) + y
Flow chart of Hebb training algorithm
Question 1: Design a Hebb network to implement AND
function:
●
Step 1: Draw the truth table of AND
●
The activation function used here is Bipolar Sigmoidal Function so the range is [-1,1].
●
Step 2: Initialize weights and bias as zero.
w1=0
w2=0
b=0
Step 3:
Step 3.1 : Consider the first input and bias : (x1, x2, b) = (1, 1, 1) and target y=1
●
Apply Hebb Rule :
– wi(new)= wi(old)+Δwi
– b(new)= b(old) +Δb
Where Δwi =xi*y and Δb=y. (ie, Δb is always equal to target y)
●
Find Δwi
– Δw1 = x1 * y = 1 * 1= 1
– Δw2 = x2 * y = 1 * 1= 1
– Δb = y = 1
➔
w1(new)=w1(old)+Δw1 = 0+1 = 1
➔
w2(new)=w2(old)+Δw2 = 0+1 = 1
➔
b(new)=b(old)+Δb = 0+1 = 1
Step 3.2 : Consider the second input and bias : (x1, x2, b) = (1, -1, 1) and target y = -1
●
Apply Hebb Rule :
– wi(new)= wi(old)+Δwi
– b(new)= b(old) +Δb
Where Δwi =xi*y and Δb=y. (ie, Δb is always equal to target y)
●
Find Δwi
– Δw1 = x1 * y = 1 * -1= -1
– Δw2 = x2 * y = -1 * -1= 1
– Δb = y = -1
➔
w1(new)=w1(old)+Δw1 = 1+-1 = 0
➔
w2(new)=w2(old)+Δw2 = 1+1 = 2
➔
b(new)=b(old)+Δb = 1+-1 = 0
Step 3.3 : Consider the third input and bias : (x1, x2, b) = (-1, 1, 1) and target y = -1
●
Apply Hebb Rule :
– wi(new)= wi(old)+Δwi
– b(new)= b(old) +Δb
Where Δwi =xi*y and Δb=y. (ie, Δb is always equal to target y)
●
Find Δwi
– Δw1 = x1 * y = -1 * -1= 1
– Δw2 = x2 * y = 1 * -1= -1
– Δb = y = -1
➔
w1(new)=w1(old)+Δw1 = 0+1 = 1
➔
w2(new)=w2(old)+Δw2 = 2+-1 = 1
➔
b(new)=b(old)+Δb = 0+-1 = -1
Step 3.4 : Consider the fourth input and bias : (x1, x2, b) = (-1, -1, 1) and target y = -1
●
Apply Hebb Rule :
– wi(new)= wi(old)+Δwi
– b(new)= b(old) +Δb
Where Δwi =xi*y and Δb=y. (ie, Δb is always equal to target y)
●
Find Δwi
– Δw1 = x1 * y = -1 * -1= 1
– Δw2 = x2 * y = -1 * -1= 1
– Δb = y = -1
➔
w1(new)=w1(old)+Δw1 = 1+1 = 2
➔
w2(new)=w2(old)+Δw2 = 1+1 = 2
➔
b(new)=b(old)+Δb = -1+-1 = -2
●
Step 4 : Draw a table showing the values of weights for all inputs
●
w1=2, w2=2 are the final weights and b=-2 is the final bias for the given input training data
using Hebb rule.
●
Hebb net for AND is :
Linear separability
●
A decision line is drawn to separate positive and negative responses.
●
The decision line may also be called as the decision-making line or decision-support line or linear-separable line.
●
The necessity of the linear separability concept was felt to classify the patterns based upon their output responses.
●
The linear separability of the nerwork is based on the decision-boundary line.
●
If there exist weights (with bias) for which the training input vectors having positive (correct:) response,+1,lie on one
side of the decision boundary and all the other vectors having negative (incorrect) response, -1, lie on the other side of
the decision boundary, then we can conclude the problem is "linearly separable."
●
Consider a network having positive response in the first quadrant and negative response in all other quadrants (AND
function) with either binary or bipolar data, then the decision line is drawn separating the positive response region from
rhe negative response region. This is depicted in Figure below
Linear separability
●
Separating positive and negative response using a boundary.
For the fourth input [ -1 - 1 1], the separating line is
Q: Using the linear separability concept, obtain the response for OR function
(take bipolar inputs and bipolar targets).
●
The truth table for OR function with bipolar inputs and targets is
●
If output is 1, it is denoted as"+" else"-."
●
Assuming thee coordinates as ( -l, 0) and (0, -l); (x1, yl) and (x2,y2), the slope "m" of the straight line can be obtained
as
●
We now calculate c as c= y1 – mx1 = 0 - (-1*-1) = -1
●
Therefore, w1 = l, w2 = 1 and b = 1.
●
Calculating the net input and output of OR function on the basis of these weights and bias
●
The truth table inputs and corresponding outputs have been plotted in Figure
Question 2: Using Hebb rule, find the weights required
to perform the classification of given pattern.
●
We have given a dataset consisting of 2 patterns : I and O.
●
The pattern is shown as a 3x3 matrix form .
●
In squares, ‘+’ symbol represents the value ‘1’ and empty
squares indicates ‘-1’.
●
Consider output I to value 1 and output O to value -1.
Step 1 : Convert the given dataset into :
Pattern Inputs Target
x1 x2 x3 x4 x5 x6 x7 x8 x9 b
I 1 1 1 -1 1 -1 1 1 1 1 1
O 1 1 1 1 -1 1 1 1 1 1 -1
●
Note : As target in such cases, select 1 & -1 respectively.