Chapter 4 Neural Network
Chapter 4 Neural Network
Neural Network
By: Yeshambel A.
Neural Network
2
The Power of Brain vs. Machine
• The Brain
– Pattern
Recognition
– Association
– Complexity
– Noise Tolerance
• The
Machine
– Calculation
– Precision 3
Features of the Brain
4
Neural Network classifier
⚫ It is represented as a layered set of interconnected processors.
⚫ The weighted outputs of these units are fed into hidden layer.
⚫ The weighted outputs of the last hidden layer are inputs to units
making up the output layer.
5
6
Neural Networks Applications
There are two basic goals for neural network research:
Brain modelling
• Aid our understanding of how the brain works. This helps to understand the nature of
perception, actions, learning and memory, thought and intelligence and/or formulate medical
solutions to brain damaged patients.
Artificial System Construction/ real world applications.
• Financial modelling – predicting the stock market
• Time series prediction – climate, weather, seizures
• Computer games – intelligent agents, chess, backgammon
• Robotics – autonomous adaptable robots
• Pattern recognition – speech recognition, seismic activity, sonar signals
• Data analysis – data compression, data mining
• Bioinformatics – DNA sequencing, alignment
7
Architecture of Neural network
⚫ Neural networks are used to look for patterns in data, learn these patterns,
& then classify new patterns & make forecasts
⚫ A network with the input and output layer only is called single-layered
neural network. Whereas, a multilayer neural network is a generalized one
with one or more hidden layer.
⚫ A network containing two hidden layers is called a three-layer neural network, and so on.
8
A Multilayer Neural Network
⚫ Input: corresponds with class attribute that are with normalized
attributes values.
– There are as many nodes as classattributes, X = {x1, x2, …. xm}, where n is the number
of attributes.
• Hidden Layer
– neither its input nor its output can be observed from outside.
– The number of nodes in the
hidden layer & the number of hidden layers depends on implementation.
– Mostly different number of hidden layers and nodes produce different result
9
Multi-layer Perceptron (MLP)
• One of the most popular neural network model is the multi-layer perceptron (MLP).
• In an MLP, neurons are arranged in layers. There is one input layer, one output
layer, and several (or many) hidden layers.
10
11
Hidden layer: Neuron with
Activation
⚫ The neuron is the basic information processing unit of a NN.
⚫ It consists of:
1. A set of links, describing the neuron inputs, with weights W1,W2,
…,Wm
2. An adder function (linear combiner) for computing the weighted sum
of the inputs (real numbers): M
y = ∑j = w xj j
1
3. Activation function (also called squashing function): for limiting the
output behavior of the neuron.
12
Activation Functions
13
Activation Functions
14
Two Topologies of neural
network
⚫ NN can be designed in a feed forward or recurrent manner
⚫ In a feed forward neural network connections
between the units do not form a directed cycle.
⚫ In this network, the information moves in only one direction, forward, from the
input nodes, through the hidden nodes (if any) & to the output nodes. There are no
cycles or loops or no feedback connections are present in the network, that is,
connections extending from outputs of units to inputs of units in the same layer or
previous layers.
⚫ In recurrent networks data circulates back &
forth until the activation of the units is stabilized
⚫ Recurrent networks have a feedback loop where data can be fed back into the input
at some point before it is fed forward again for further processing and final output.
15
Training the neural
⚫ network
The purpose is to learn to generalize using a set of sample
patterns
where the desired output is known.
⚫ Back Propagation is the most commonly used method for
training
multilayer feed forward NN.
⚫ Back propagation learns by iteratively processing a set of training
data (samples).
⚫ For each sample, weights are modified to minimize the
error between the desired output and the actual output.
⚫ After propagating an input through the network, the error is
calculated and the error is 16
Training
Algorithm
⚫ The learning algorithm is as follows
⚫ Initialize the weights and threshold to small random
numbers.
⚫ Present a vector x to the neuron inputs and calculate
m the
output using the adder
y = ∑j j
function. w
⚫ Apply the activation function (in this case step
functionx) j=
such that y = 0 if y 1
0
1 if y >
⚫ Update the weights according to the
0
error.
W j =W j +η (yT
17
Training Multi-layer NN
18
Training Multi-layer NN
19
Training Multi-layer NN
20
Training Multi-layer NN
24
Calculating the Error: Example
25
Reducing Error
• The main goal of the training is to reduce the error or the difference between
prediction and actual output.
• By decomposing prediction into its basic elements we can find that weights are the
variable elements affecting prediction value. In other words, in order to change
prediction value, we need to change weights values.
26
Pros and Cons of Neural Network
• Useful for learning complex data like handwriting, speech and
image recognition
Cons
Pros Slow training time
Can learn more complicated
Hard to interpret & understand the learned
class boundaries
Fast application function (weights)
Can handle large number of Hard to implement: trial & error for
features choosing number of nodes
o Neural Network needs long time for training.
o Neural Network has a high tolerance to noisy and incomplete
data
o Conclusion: Use neural nets only if decision-trees fail.
27
Deep Learning…
28
Deep Learning…
29
Convolutional Neural Networks (CNNs)
• CNNs are a special kind of multi-layer neural networks, designed for processing data
that has an input shape like a 2D matrix like images.
• Images are 2D matrix of pixels on which we run CNN to either recognize the image or
to classify the image.
30
Convolutional Neural Network Architecture
31
Convolutional Neural Network Architecture
• Convolutional layer is the core building block of a CNN, and it is where the
majority of computation occurs.
• The term convolution refers to the mathematical combination of two functions to
produce a third function. It merges two sets of information.
• In the case of a CNN, the convolution is performed on the input data with the use of a
filter or kernel then produce a feature map.
32
Convolution Operation
33
Convolution Operation
34
Pooling Layer
The pooling Layer is a mechanism of down sampling. It is usually appended after
convolutional layers to progressively decrease the spatial size of feature maps.
35
The whole CNN
cat dog
…… Convolution
Max Pooling
Can
Fully Connected repea
Feedforward network
Convolution t
many
times
Max Pooling
Flattened
36
Recurrent Neural Networks (RNN)
• A recurrent neural network (RNN) is an extension of a regular
feedforward neural network, which is able to handle variable-length
sequential data and processing time-series prediction.
• Example: If you want to predict the next word in a sentence you need
to know which words came before it.
• In sequence problem, the output depends on
• Current Input
• Previous Output
• Example: Sequence is important for part of speech (POS) tagging
• Traditional neural network cannot capture such relationship.
37
Typical RNN Architecture
RNN can be seen as an MLP network with the addition of loops to the
architecture.
38
RNN Example: Guess part of speech (POS)
39
RNN Example: Sentiment Analysis
40
Recurrent Neural Networks: Process
Sequences
46