Unit 1 Introduction to Soft Computing
Unit 1 Introduction to Soft Computing
Soft Computing
Outline
• What is Computing?
• Soft Computing & Hard Computing
• Introduction to Neural Network: Biological Neuron
• Fundamental concept of Artificial Neural Network & Biological
Neural Network
• Evolution of Neural Networks
• Basic Models of Artificial Neural Networks
• Types of Learning
• Important Terminologies of ANNs
• Idea of computational units & Activation Functions
• McCulloch–Pitts unit and Thresholding logic
•
Computing
• Before diving into soft computing, it's essential to first
understand what computing is and familiarize ourselves with the
core terminologies related to computing.
• The following diagram represents the basic process that occurs in
computing:
• In this diagram, we observe that there is a function, f, which
takes some input, x, and produces an output, y. The input is
referred to as the Antecedent, while the output is called
the Consequent.
• The function f can also be called a formal method, algorithm,
or a mapping function. It represents the logic or steps used to
process the input and generate the output.
• The middle part of this diagram is known as the computing
unit, where the function resides. This is where we feed the input,
and a process occurs to convert that input into the desired
output y.
• In the computing process, the steps that guide how the input is
manipulated are called control actions.
• These control actions ensure that the input gradually approaches
the desired output. The moment the process completes, we
obtain the final result, known as the Consequent.
Basic Characteristics Related to
Computing
• Precise Solution: Computing is used to produce a solution that
is exact and definitive.
• Unambiguous & Accurate: The control actions within the
computing unit must be unambiguous, meaning they must have
only one interpretation. Each control action should also be
accurate to ensure that the process is valid and reliable.
• Mathematical Model: A well-defined algorithm is a requirement
for solving any problem through computing. This algorithm is
essentially a mathematical model that represents the problem
and its solution process.
Type of Computing
• Hard Computing
• Soft Computing
Hard Computing
• Hard computing refers to a traditional computing approach where
the results are always precise and exact.
• Ease of Implementation:
• Soft computing techniques like fuzzy logic and genetic algorithms are often
easier to implement for complex, real-world problems compared to
traditional methods.
• They don’t require a precise model of the system but instead learn from
examples.
• Example: In control systems, fuzzy logic can be quickly applied to model
human-like decision-making without needing complex mathematical
Importance of Soft Computing
• Incorporates Human-Like Reasoning:
• Soft computing allows for reasoning based on approximate data,
mimicking human decision-making.
• Neural Networks: Modeled after the human brain, these networks learn
from data and improve over time. They are used in areas like image
recognition, speech processing, and autonomous systems.
• Inside the neuron, there is a cell body (also known as the soma),
and within the cell body, we find the nucleus.
• The dendrites collect the input signals, and the cell body processes
that input. Once processed, the output is transferred via the axon.
• The axon is the part of the neuron that carries the output signals to
other neurons.
Biological Neural Network
• In the human brain, we have billions of neurons, and the
dendrites of one neuron connect with the axons of other neurons.
• The point where two neurons connect is called a synapse.
Information is stored and transferred across these synapses.
• As we store more information in our brains, the synapses
strengthen, allowing us to retain that information.
• With billions of neurons, we also have billions of synapses, which
play a key role in memory and learning.
• For example, when we read a question in an exam, the
information is sent to our brain through neurons. Another
example is when a mosquito bites us; the signal of pain is sent to
our brain, and we respond to it through neural signals.
Biological Neural Network
Definition of Biological Neural Network
• A biological neural network is a network of neurons that processes
and transmits information in the brain. It is the basis of how humans
think, learn, and make decisions. The neurons communicate with
each other through synapses, which strengthen as we store more
information, allowing us to retain and recall data.
• By adjusting the weights, the ANN can learn which inputs are
more significant for making accurate predictions or decisions. The
net input to node C is calculated as follows:
Net Input = x1 * w1 + x2 * w2
Model of Artificial Neural Network
• This calculation provides the net input to node C, but to determine the
actual output, we need to apply an activation function to the net input.
• The net input to the output node is calculated similarly, but with many
more inputs and weights. The final output is determined after applying
the activation function to the net input.
Model of Artificial Neural Network
• For above neuron architecture , the net input has to be calculated in the way.
yin = x1w1+x2w2
• The output yin of the output neuron Y can be obtained by applying activations
over the net input .
y =f(yin)
• The function to be applied over the net input is called activation function
Basic Models of Artificial Neural Networks
• To understand Artificial Neural Networks (ANN), we must first examine its
foundational components.
• Just like any structure, a neural network is built upon certain key elements that
define how it processes information, learns from data, and makes predictions.
• Architecture of ANN
• Architecture refers to the layout or structure of an ANN. It is how the neurons
(units) are organized in layers and how these layers are connected to each other.
• Layers: An ANN typically consists of three types of layers:
• Input Layer: Receives the raw data (like images, numbers, etc.) and passes it on to the next
layer.
• Hidden Layer(s): These layers process the input and extract patterns. The number of hidden
layers and neurons in each layer can vary.
• Output Layer: Provides the final result (e.g., a classification label or prediction).
Basic Models of Artificial Neural Networks
• The architecture of a neural network defines how data flows through the network,
from input to output, and how decisions are made at each step.
• Connection with Weights: The architecture alone does not make the network
functional.
• Weights determine the strength and impact of each connection on the final output.
Setting of Weights
• Weights are numerical values that control how much influence one neuron has
over another.
• Every connection between neurons has a weight associated with it, and these
weights are learned during the training process.
Basic Models of Artificial Neural Networks
• Initial Weights: At the start, weights are usually assigned randomly. These
weights are adjusted as the network learns from the data.
• Role of Weights: The higher the weight between two neurons, the stronger the
connection, meaning the output from one neuron has a greater influence on the
next neuron’s decision.
• Learning: During training, the network adjusts the weights to minimize errors in
its predictions. This process is called training the network, and it’s essential for the
network’s ability to learn from data.
Basic Models of Artificial Neural Networks
• Connection with Activation Functions: Once the weights determine how much
influence one neuron’s output
• need a mechanism to decide whether the output should be passed forward or
"activated.“
Activation Functions
• An activation function is a mathematical function that determines whether a
neuron should be activated (fired) based on the weighted sum of its inputs.
• It introduces non-linearity to the network, allowing it to solve complex problems.
Basic Models of Artificial Neural Networks
• Importance of activation function: let us assume a person is performing some
task.
• To make the task more efficient and to obtain correct results, some force or
motivation may be given in achieving the correct results.
• In a similar way, the activation function is applied over the net input of the
network to calculate the output of an ANN so that we get a better output or result.
• Type of Activation Function
• 1: Identity Function
• 2: Binary Step Function
• 3: Bipolar Step Function
• 4: Sigmoidal Activation Functions
• Ramp Activation Function
Identity
Function
• Also known as the linear function because the
output is identical to the input.
• It can be defined as:
f(x) = x for all x.
Here, if the net input is x, then the output will
also be x.
• The input layer often uses the identity
activation function because no transformation
is needed.
Binary Step
Function
• This function can be defined as:
f(x) = 1 if x ≥ θ
f(x) = 0 if x < θ
• where θ is the threshold value. If the net input (x) is greater
than or equal to this threshold value, the output is 1,
otherwise, it is 0.
• It is widely used in single-layer neural networks where the
output needs to be binary (either 0 or 1).
Bipolar Step
Function
• Similar to the binary step function, but it outputs either
+1 or -1 instead of 1 or 0.
• It can be defined as:
f(x) = 1 if x ≥ θ
f(x) = -1 if x < θ
• Used when outputs are expected to be in the range of +1
and -1, often in single-layer networks.
Sigmoidal Activation Functions
• Sigmoidal functions introduce non-linearity to the network and are widely used in
backpropagation-based neural networks. There are two main types:
• a) Binary Sigmoidal Function (Logistic Function)
• b) Bipolar Sigmoidal Function
Sigmoidal Activation Functions
• Binary Sigmoidal Function (Logistic Function)
• It can be defined as:
f(x) = 1 / (1 + e^−λx)
where λ (lambda) is the steepness parameter, and x is the net input.
• The output of the binary sigmoidal function is always between 0 and 1.
• This function has a peculiar property: its derivative is:
f′(x) = λf (x)(1 − f(x))
Sigmoidal Activation Functions
• It can be defined as:
f(x) = (2 / (1 + e^−λx) )− 1
where λ (lambda) is the steepness parameter, and x is the net input.
• The output of the bipolar sigmoidal function ranges from -1 to +1.
• Its derivative is:
f′(x) = λ/2 * (1 + f(x)) (1 − f(x))
Ramp Activation
Function
• This function is a combination of step and linear functions.
• It can be defined as:
f(x)=1 if x > 1
f(x)=0 if x < 0
f(x)=x if 0 ≤ x≤ 1
• It outputs 0 for inputs less than 0, increases linearly with inputs
between 0 and 1, and outputs 1 for inputs greater than 1.
• Activation functions play a vital role in artificial neural networks
by introducing non-linearity and helping the network learn
complex patterns.
Sigmoid Activation Function Solved
Example
• In this case, we have a neural network with an input layer and an
output layer. The input layer has three neurons, and the output
layer has one neuron.
• The inputs are 0.8, 0.6, and 0.4.
• The bias weight is 0.35.
• The weights associated with the three neurons are 0.1, 0.3,
and −0.2.
Sigmoid Activation Function Solved
Example
• To calculate the net input yn, we find the sum of the product of
the inputs and weights. The equation looks like this:
• yn=B+∑i=1n(xi⋅wi)In this case, n is the number of input neurons,
which is 3.
• Expanding the equation:
• yn=B+(x1⋅w1)+(x2⋅w2)+(x3⋅w3)Substituting the values:
Sigmoid Activation Function Solved
Example
• Bias (B) = 0.35
• x1=0.8,w1=0.1
• x2=0.6,w2=0.3
• x3=0.4,w3=−0.2
• Now solving the equation:
• yn=0.35+(0.8⋅0.1)+(0.6⋅0.3)+(0.4⋅−0.2)
• After calculation, we get yn=0.53 as the net input to the neuron.
• Now we can use this net input to find the outputs:
Sigmoid Activation Function Solved
Example
• Binary Sigmoid Activation Function: Using the net input in
the binary sigmoid equation, we get: output=1/1+e−0.53≈0.628
• Bipolar Sigmoid Activation Function: Using the net input in
the bipolar sigmoid equation, we
get: output=2/1+e−0.53−1≈0.257
Bias
• The bias is a constant value included in the network. Its impact is seen in
calculating the net input.
• The bias is included by adding a component x0 =1 to the input vector X.
• Bias can be positive or negative.
• The positive bias helps in increasing the net input of the network.
• The negative bias helps in decreasing the net input of the network.
Threshold
• Threshold is a set value used in the activation function.
• In ANN, based on the threshold value the activation functions are defined and the
output is calculated.
Learning Rate
• The learning rate is used to control the amount of weight adjustment at each step
of training.
• The learning rate ranges from 0 to 1.
• It determines the rate of learning at each time step.
McCulloch-Pitts Neuron
• he McCulloch-Pitts (MP) neuron, introduced in 1943 by Warren McCulloch and
Walter Pitts, is one of the earliest models of artificial neural networks.
• This pioneering work laid the foundation for the field of neural computing and
artificial intelligence.
• The MP neuron was designed to mimic the functioning of biological neurons in
the human brain, aiming to represent logical operations in a simplified manner.
• Unlike more complex models, the MP neuron operates based on binary inputs and
outputs, effectively simulating the way neurons fire in response to stimuli.
McCulloch-Pitts Neuron
• it serves as a fundamental building block in understanding neural networks and
provides insights into how information processing occurs within more
sophisticated models.
• This model is crucial for grasping essential concepts in neural networks, including
activation functions, thresholds, and the basic principles of learning.
• If θ>1, the neuron will not fire in cases where X2 is high (1).
• This function confirms that the neuron will fire (output 1) only
when X1 is equal to 1 and X2 is equal to 0, effectively
implementing the ANDNOT logical function.
Hebb Network / Hebbian Rule
• 1. Introduction to Hebbian Rule
• The Hebbian Rule is one of the simplest learning rules under artificial neural
networks. It was introduced in 1949 by Donald Hebb.
• According to Hebb, learning in the brain occurs due to changes in the synaptic
gap, which can be attributed to metabolic changes or growth. This rule is based on
the biological processes that occur in the brain during learning.
• To understand the Hebbian Rule, let’s first consider the structure of a biological
neuron. Each neuron has three main parts:
• Cell Body (Soma): This is where the nucleus is located.
• Axon: A long connection extending from one neuron to another.
• Dendrites: Small nerves connected to the cell body that transmit electrical
impulses.
Hebb Network / Hebbian Rule
• The electrical impulses are passed from one neuron to another through synapses,
which are small gaps between neurons. When learning occurs, metabolic changes
happen in the synaptic gap, leading to the formation of new connections between
neurons.
• 2. Hebbian Rule Definition
• Donald Hebb's definition of the Hebbian Rule is as follows:
• When an axon of cell A is near enough to excite cell B and repeatedly or
persistently fires it, some growth process or metabolic change takes place in one
or both cells.
Hebb Network / Hebbian Rule
• In simpler terms, if neuron A excites neuron B frequently, changes occur in their
synaptic gap, which strengthens the connection between the two neurons.
• Hebb's Rule was inspired by the way learning happens in the human brain.
• A relatable example of this can be seen when learning to drive.
• Initially, when you start driving, you are conscious of every action, like turning or
reversing.
• However, over time, as it becomes a habit, you can drive effortlessly while doing
other tasks, like listening to music.
• This example demonstrates how neurons become trained and perform tasks
automatically over time, which is the core idea of Hebb’s learning theory.
Hebb Network / Hebbian Rule
• 3. Principles of Hebbian Rule
The Hebbian Rule follows two basic principles:
ΔW = xi * y
Where:
• Wnew: New weight after learning
• Wold: Initial weight
• ΔW: Change in weight (synaptic gap change)
• xi: Input vector
• y: Output vector
Hebb Network / Hebbian Rule
• Training Algorithm for Hebbian Network
• The training algorithm for the Hebbian Network follows these
steps:
• Initialize the weights and bias: Set the weights and bias to
either zero or random values.
• For each input-output pair: Perform the following:
• Set the activation for the input unit: Xi = Si
• Set the activation for the output unit: y = T
• Update the weights and bias using the formulas:
Wnew = Wold + xi * y
Bnew = Bold + y
Hebb Network / Hebbian Rule
• Repeat the process until there are no more input-output pairs.
• This training algorithm allows the Hebbian Network to learn and
update its weights and bias, forming the basis for unsupervised
learning in neural networks.
Hebb Network / Hebbian Rule
Applications of Hebbian Rule
• The Hebbian learning rule is widely used in various applications,
including:
• Pattern Association: Associating different patterns based on
inputs.
• Pattern Categorization: Categorizing inputs based on learned
patterns.
• Pattern Classification: Classifying new inputs based on
previously learned patterns.
• In conclusion, Hebb's rule and network play a foundational role in
understanding how neurons learn and adapt. The rule is simple
yet powerful, forming the basis for more complex neural network
models in artificial intelligence.
Hebbian Network for Logical AND
Function (Bipolar Inputs)
• We are tasked with designing a Hebbian network to implement
the logical AND function using bipolar inputs (1 or -1) and targets.
We will initialize the weights (W1, W2) and bias (B) to zero and use the Hebbian learning
rule to update the weights based on the input-output pairs.
Weight Update Rule
The weight and bias update rules in Hebbian learning are as follows:
W1(new) = W1(old) + X1 * Y
W2(new) = W2(old) + X2 * Y
B(new) = B(old) + Y
Step-by-Step Calculation
Initial Weights: W1 = 0, W2 = 0, B = 0
Hebbian Network for Logical AND
Function (Bipolar Inputs)
Hebbian Network for Logical AND
Function (Bipolar Inputs)
• There are 4 training samples, so there will be 4 iterations. Also, the
activation function used here is Bipolar Sigmoidal Function so the range is
[-1,1].
• Step 1 :
• Set weight and bias to zero, w = [ 0 0 0 ]T and b = 0.
• Step 2 :
• Set input vector Xi = Si for i = 1 to 4.
X1 = [ -1 -1 1 ]T
X2 = [ -1 1 1 ]T
X3 = [ 1 -1 1 ]T
X4 = [ 1 1 1 ]T
• Step 3 :
Hebbian Network for Logical AND
Function (Bipolar Inputs)
Step 4 :
• Modifying weights using Hebbian Rule:
• First iteration -
• w(new) = w(old) + x1y1 = [ 0 0 0 ]T + [ -1 -1 1 ]T . [ -1 ] = [ 1 1 -1 ]T
• For the second iteration, the final weight of the first one will be used
and so on.
• Second iteration -
• w(new) = [ 1 1 -1 ]T + [ -1 1 1 ]T . [ -1 ] = [ 2 0 -2 ]T
• Third iteration -
• w(new) = [ 2 0 -2]T + [ 1 -1 1 ]T . [ -1 ] = [ 1 1 -3 ]T
• Fourth iteration -
• w(new) = [ 1 1 -3]T + [ 1 1 1 ]T . [ 1 ] = [ 2 2 -2 ]T
Hebbian Network for Logical AND
Function (Bipolar Inputs)
• So, the final weight matrix is [ 2 2 -2 ]T
• Testing the network :
Hebbian Network for Logical AND
Function (Bipolar Inputs)
• For x1 = -1, x2 = -1, b = 1, Y = (-1)(2) + (-1)(2) + (1)(-2) = -6
• For x1 = -1, x2 = 1, b = 1, Y = (-1)(2) + (1)(2) + (1)(-2) = -2
• For x1 = 1, x2 = -1, b = 1, Y = (1)(2) + (-1)(2) + (1)(-2) = -2
• For x1 = 1, x2 = 1, b = 1, Y = (1)(2) + (1)(2) + (1)(-2) = 2