NN 02
NN 02
Course Outlines
1. Introduction to NNs
2. Main characteristics of Neural Networks
3. Resenblatt’s perceptron Single Layer Network
4. Least Mean Square algorithm for Single Layer Network
5. Multilayer Perceptron (MLP) Network
6. Optimization of Back-Propagation Algorithm
7. Deep Learning
8. Convolutional Neural Networks (CNNs)
9. Regularization and CNNs
10. YOLO for Object Detection
11. Fully CNNs and U-Net for Image Segmentation, Generative Models
1
The main characteristics of Neural Network
❑Activation function:
❑ Are mathematical functions that limit the range of output values of a node.
❑Architecture or Structure :
❑ The connectivity of neurons (nodes) determines the neural network structure (architecture).
❑The manner in which the neurons of neural network are structured is intimately linked with the learning
algorithm used to train the network.
Agenda
➢Activation Function
▪ Types of Activation Function
▪ Stochastic Model of a Neuron
2
Activation Function and Squashing
oThe mapping from net unit activation to output may be characterized by
activation or squashing function.
oWhy do we need activation functions?
▪ Non-linearity is achieved through the use of activation functions, which limit or squash
the range of values a neuron can express.
▪ The squashing function serves to limit the domain (0 to 1 or -1 to 2).
y k = f (netk ) = netk
3
2- Threshold (Step) function
❑The output of neuron k employing such a threshold function is expressed as
1 ifv k 0
y k = (vk ) =
0 ifv k 0
• The model uses this function is proposed by McCulloch and Pitts in 1943.
• That is, the neuron will have output signal only if its activation potential is non-
negative, a property known as all-or-none.
• Is it continuous function?
X1=3 0.3
uk = netk = W T X
= 3(0.3) + 1(-0.1)+ 0(2.1) + - 2(-1.1) X2=1 -0.1
4
3- Symmetric Threshold function with bi-polar output
1 if vk 0
y k = (vk ) =
− 1 if vk 0
4- Sigmoid function
• The math of some neural nets requires that
the activation function be continuously
differentiable.
• It is defined as a strictly increasing function.
• The sigmoid function has a s-shaped graph.
• An example of the sigmoid function is the
logistic function, defined by.
1
yk = (vk ) =
1 + exp(−avk )
where a is the slop parameter of the sigmoid function.
5
5- Sigmoid function, cont.
By varying the parameter a, we obtain sigmoid functions of different slopes, as
illustrated in the next figure:
6
6- Ramp function or
Rectified Linear Unit (ReLU)
(sometimes called linear threshold neurons)
It can be expressed by numerous definitions, for example "0 for negative inputs, output
equals input for non-negative inputs".
v = b + wi xi
i
v if v 0
y=
0 otherwise
7- Piecewise-Linear function
• It is a function whose graph is composed of straight-
line sections.
1
1 ifvk
2
1 1
yk = (vk ) = vk + 0.5 if − vk
2 2
1
0 ifvk −
2
7
8- Softmax function
❑ Also called the normalized exponential function. Generalization of the logistic
function.
Example
Using the sigmoid function with slop equal 2 for neuron have an input (3, 1, 0, -2) and
weight (0.3, -0.1, 2.1, -1.1), calculate the output of that neuron?
X1=3 0.3
8
Example
Given a two-input neuron with the following parameters: b = 1.2, W=[ 3 2], and X=[-5 6]T, calculate the neuron
output for the following transfer functions:
i. A symmetrical Threshold transfer function
ii. A linear transfer function
iii. A hyperbolic tangent sigmoid transfer function
Solution: − 5
net = 3 2 + (1.2)
6
= −15 + 12 + 1.2 = − 1.8
i. y = symmetricthreshold(−1.8) = −1
ii. y = linear(−1.8) = −1.8
iii. y = hyperbolic tangent sigmoid (-1.8) = (1- exp(1.8))/(1 + exp(1.8)) = -0.7163
NEURAL NETWORKS - LECTURE 2 18
9
Agenda
➢Activation Function
▪ Types of Activation Function
▪ Stochastic Model of a Neuron
➢Deterministic modeling gives you the same exact results for a particular set of
inputs, no matter how many times you re-calculate the model.
➢The mathematical properties are known.
➢ None of them is random.
➢There is only one set of specific values and only one answer or solution to a problem.
➢With a deterministic model, the uncertain factors are external to the model.
10
Stochastic Model of a Neuron
➢In some applications it is desirable to have a stochastic neuron model.
◦ Stochastic modeling, on the other hand, is inherently random.
◦ The uncertain factors are built into the model.
◦ That is, the neuron is permitted to reside in only one of two states; +1 and -1. The
decision for a neuron to fire (i.e., switch its state from “off” to “on”) is probabilistic.
◦ Example 1: Predict how company balance sheets will look at a given point in the future
◦ Example 2: Profitability ratio in the stock investing in the future coming six months.
11
Agenda
➢Activation Function
▪ Types of Activation Function
▪ Stochastic Model of a Neuron
1. Feedforward Networks
12
1- Feedforward Networks
These are the commonest type of neural network in practical applications.
– The first layer is the input and the last layer is the output.
– If there is more than one hidden layer, we call them “deep” neural
networks.
1- Feedforward Networks
Characteristics
❑Hierarchical: the neurons are arranged in separate layers
have no loops.
❑The neurons in one layer delivers its output to the next layer.
13
1- Feedforward Networks, cont.
Types
1. Single-layer Feedforward Networks
◦ Single-Layer Feedforward Network is the
simplest form of layered network.
◦ The “signal-layer” referring to the output layer.
◦ It has an input layer of source nodes that
projects onto an output layer of neurons
(computation nodes), but not vice versa.
◦ A network is called a single-layer network,
because we do not count the input layer since
no computation is performed there.
Where:
❑O1, O2 ,…,Om are the output nodes.
❑X1, X2, …, Xn are the input nodes.
❑F is the activation (transfer) function.
row i in the weight matrix, Wi1, Wi2, …, Win , represent the weight associative with output
node Oi .
and column j in the weight matrix, W1j, W2j, …, Wmj , represent the weight associative with
input node Xj .
NEURAL NETWORKS - LECTURE 2 29
14
1- Feedforward Networks, cont.
Types
2. Multilayer Feedforward Networks
▪ Contains:
▪ Input layer (source nodes)
➢ It is said to be fully connected in the sense that every node in each layer of the
network is connected to every other node in the adjacent forward layer;
otherwise, it is called partially connected if some of the weight connections are
missing from the network.
NEURAL NETWORKS - LECTURE 2 30
2- Recurrent Networks
◼It has at least one feedback loop.
◼The network may have or not hidden neurons.
◼There could be neurons with self-feedback links;
that is the output of a neuron is fed back into its self
as input.
◼They are more biologically realistic.
➢Recurrent neural networks are a very natural way to model sequential data. For example,
it is the most appropriate for predicting the price of a stock.
➢Feedback connection takes the output of the previous data in a series as its next
input.
➢They have the ability to remember information in their hidden state for a long time.
15
2- Recurrent Networks, cont.
◼ Example: Hopfield network is a special kind of
the recurrent network:
▪ The connections between units are symmetrical (they have the
same weight in both directions).
▪ The connections is bidirectional.
◼ There is no hierarchical arrangement.
◼ Consist of a single layer of neurons (I/P & O/P).
◼ No hidden layer.
◼ No self-feedback loops.
16
2- Recurrent Networks, cont.
Another example: Boltzmann machines
◦ It is a Symmetrically connected networks with hidden units.
Feedback connection
Feedback is said to exist in dynamic systems whenever the output of a
node influences in part the input of that particular node. (Very
important in the study of recurrent networks).
yk (n) = A[ xj (n)]
and
xj (n) = x j (n) + B[ yk (n)]
Figure 12 Signal-flow graph of a single-
A loop feedback system.
yk ( n ) = [ x j ( n)]
1 − AB
35
17
Agenda
➢Activation Function
▪ Types of Activation Function
▪ Stochastic Model of a Neuron
18
Learning Approaches in NNs
▪The learning methods in Neural Networks are classified into two basic types:
1- Learning with a Teacher (Supervised Learning)
2- Learning without Teacher (Unsupervised Learning)
19
1- Learning with a teacher, cont.
◼ The learning algorithm tries to minimize the error between the desired
response t and the actual output y.
Tasks:
◦ Pattern classification
◦ Object Recognition
◦ Regression
20
1- Learning with a teacher, cont.
Neural Networks Classifier vs Regressor
✓Label Data: Each training case consists of an input vector x and a
target output t.
• Regression: The target output is a real number or a whole vector of
real numbers.
– The price of a stock in 6 months time.
– The temperature at noon tomorrow.
• Classification: The target output is a class label.
– The simplest case is a choice between 1 and 0.
– We can also have multiple alternative labels.
Tasks:
◦ Dimensionality reduction
◦ Clustering
21
2- Unsupervised Learning, cont.
Unsupervised Learning algorithms :
◦ Hebbian Learning
◦ Used for Dimensionality reduction
◦ Similar to Principal Component Analysis (PCA)
◦ Competitive learning
◦ Used for Clustering - The NN must identify clusters in the input data and
discover classes automatically
◦ Self-organizing features map (SOFM) are neural network model for
unsupervised learning.
22
Learning Tasks
Supervised Unsupervised
Learn to predict an output when Discover a good internal representation
given an input vector. of the input, i.e. find similarities and
Data: differences between data points.
Labeled examples Data:
(input , desired output) Unlabeled examples
Tasks: (different realizations of the input)
pattern classification Tasks:
object recognition clustering
regression dimensionality reduction
NN models: NN models:
- Perceptron - Self-organizing maps (SOM)
- Adaline - Hopfield networks
- Multilayer feed-forward NN - Principal Component Analysis
- Radial basis function (PCA)
Neural
Networks
Error correction
Learning Rule Stochastic Gradient Competitive Hebbian
descent
Backpropagation
Least Mean Square
Algorithm
23
Learning rules
There are four basic types of learning rules:
◦ Hebbian,
◦ Error correction Gradient descent,
◦ Competitive and
◦ Stochastic learning (ex.:Boltzmann Machine)
Feedforward Recurrent
24
What’s Next Lecture
25