0% found this document useful (0 votes)
8 views29 pages

Lec4-Learning Problem& Cognitive Modelling

The document discusses various learning algorithms and cognitive modeling techniques, focusing on neural networks and their training methods such as stochastic gradient descent and backpropagation. It highlights the importance of learning rates, mini-batch learning, and advanced architectures like LSTMs for handling long-term dependencies in sequential data. Additionally, it covers applications of LSTM networks in text generation, image processing, speech recognition, and language translation.

Uploaded by

ferrarisxyz
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views29 pages

Lec4-Learning Problem& Cognitive Modelling

The document discusses various learning algorithms and cognitive modeling techniques, focusing on neural networks and their training methods such as stochastic gradient descent and backpropagation. It highlights the importance of learning rates, mini-batch learning, and advanced architectures like LSTMs for handling long-term dependencies in sequential data. Additionally, it covers applications of LSTM networks in text generation, image processing, speech recognition, and language translation.

Uploaded by

ferrarisxyz
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Learning Problem&

Cognitive Modelling
Prof. Magdy M. Aboul-Ela

Dr. Heba Zaki


[Link]@[Link]
What about learning?
• In the previous Lec, the neural networks were simple enough that we could
set the connection strengths by hand to perform the desired computations.
• This is not a feasible general strategy, since models get much more
complex
• Moreover, we would like computational tools for trying to understand
learning and cognitive development

2
Connection strengths
• In practice, connection strengths are almost never set by hand.

3
4
Learning by optimizing an objective function

5
Logistic regression = single connectionist
neuron
• Logistic regression only accepts 0 or 1 discrete output, whereas this
formulation can accept 0-1 continuous output.
• Logistic regression uses a negative log-likelihood loss. This measures the
performance of a classification model where the output is a probability value
between 0 and 1.
• It is designed to fit a Maximum Likelihood Estimate (MLE). This
ensures the model parameters are chosen to maximize the probability of the
observed data occurring.
6
A naive, informal algorithm: Parameter
wiggling
• Computing the error:
• x = [1, 1]
• ŷ = 0.26 (predicted output)
• y = 1.0 (target)
• E(w,b) = 0.54 (squared error)
• What if we try wiggling each parameter?
• If we increase w0 by 0.02, our error E(w,b) becomes 0.51
• If we decrease w0 by 0.02, our error E(w,b) becomes 0.55 7
A smarter algorithm: stochastic gradient
descent
• Computing the gradient tells us which direction to go for steepest
descent:

• α : learning rate

8
9
Learning via stochastic gradient descent

• Computing the error:


• x = [1, 1]
• ŷ = 0.26 (predicted output)
• y = 1.0 (target)
• E(w,b) = 0.54 (squared error)
= 2(0.26-1)(0.26)(1-0.26)1 = - 0.285
10
(if we increase weight, error goes down)
Visualizing an update to the weights

Notice that the new prediction


is a little bit better! (closer to
• Update with gradient descent the target y = 1.0)
11
Learning via stochastic gradient descent (Cont.)

• We repeatedly cycle through each pattern in the training set, making updates
after each pattern as in the previous slide.

12
Failing to learn XOR with a linear classifier
(“one or the other, but not both”)

13
Learning XOR with a multi-layer classifier

14
15
Backpropagation algorithm for computing
gradient
• Updates for these weights the same as before:
• Multi-step strategy:

Step 1) Compute how error changes as a function of hidden unit activation (we
worked most of this step out already for single layer net)
Step 2) Compute how hidden unit activation changes as a function of weight
• As before, update with gradient descent:
• Conceptually, still no different than wiggling w3 and seeing how error
changes! 16
Important tricks for training neural networks

• The learning rate is extremely important


• Your model may not learn if you set the rate too high or too low.
• Often, you want to start the rate high and decrease it over the course of
learning.
• Mini-batch learning
• Instead of updating the network after every single training example,
we group several examples into a mini-batch.
• This is more stable and usually much faster 17
Important tricks for training neural networks
(cont.)
• The are much better activation functions than the “sigmoid”.

• Classification requires a different loss and activation function


• Softmax output layer (for c possible classes)
• Loss Function (negative log-likelihood loss)
18
Backpropagati
on allows us
to efficiently
optimize
a wide range
of “deep
neural
network”
models 19
Key principles of deep learning for data science
and machine learning
• Learning is central. Models should have a very large number of
parameters, and you should feed your model as much data as
possible.
• Learning from raw data. Learn from the raw data if possible. It
is better to learn a representation of your data than to hand-craft
a representation.
• Gradient-based learning. Gradient descent is very effective in
high-dimensional parameter spaces (e.g., millions of weights).
20
RNN [memory]
• Type of deep learning model designed to process sequential data, such as text,
speech, or time series, by incorporating loops that allow it to maintain a form of
memory, considering past inputs to influence current predictions and outputs. the
output from the previous step is fed as input to the current step.
• In traditional neural networks, all the inputs and outputs are independent of each
other, but in cases when it is required to predict the next word of a sentence, the
previous words are required and hence there is a need to remember the previous
words.
• The main and most important feature of RNN is its Hidden state, which
remembers some information about a sequence. 21
Hopfield Networks
• Hopfield networks are a beautiful form of Recurrent Artificial Neural
Networks (RNNs)
• Hopfield Networks were the first instance of associative neural
networks: (ANN)
RNN architectures which are capable of producing an emergent
associative memory.
• Associative memory, or content-addressable memory, is a system in which a
memory recall is initiated by the associability of an input pattern to a
memorized one.
22
What is Recurrent Neural
Network (RNN)?

• These parameters are updated


using Backpropagation.

• However, since RNN works on


sequential data here we use an
updated backpropagation which
is known as
• Backpropagation through time
(BPTT).
Slide
23
Self-Organizing Networks

• Self-Organizing Neural Network (SONN) most famously refers to the


Self-Organizing Map (SOM), also known as the Kohonen Map

• The SOM is a powerful type of Artificial Neural Network (ANN) used


for unsupervised learning, primarily for dimensionality reduction and
data visualization. It is designed to produce a low-dimensional (typically
2D) representation of the input data space.
24
The Problem of Long-Term Dependencies
[learning]
• “LSTMs,” a very special kind of recurrent neural network which works, for
many tasks, much better than the standard version.
• Almost all exciting results based RNNs are achieved with them.
• Sometimes, we only need to look at recent information to perform the present
task. For example, consider a language model trying to predict the next word
based on the previous ones.
• If we are trying to predict the last word in “the clouds are in the sky” we don’t
need any further context – it’s pretty obvious the next word is going to be sky.
25
The Problem of Long-Term Dependencies
• Consider trying to predict the last word in the text
“I grew up in France… I speak fluent French.”
• Recent information suggests that the next word is probably the name of a
language, but if we want to narrow down which language, we need the context
of France, from further back.
• It’s entirely possible for the gap between the relevant information and the point
where it is needed to become very large.
• Unfortunately, as that gap grows, RNNs become unable to learn to connect the
information.
• Sadly, in practice, RNNs don’t seem to be able to learn them, but LSTMs don’t
have this problem!
26
LSTM Networks architecture
• LSTM architecture has three gates
using which regulate the flow of
information.
• These gates are used to protect and
control the cell state.
• Whether information is useful or not is
decided by various gates in LSTM.
• These gates can learn and unlearn
information based on its relevance.

27Slide
27
Applications of LSTM Networks
1- Text generation or language modelling involves the calculation of words
whenever a sequence of words is supplied as input.
Language models can be used at the level of characters or n-gram level as
well as at the sentence or the level of a paragraph.
2- Image processing is the process of the analysis of a photograph and
converting the result into sentences. In order to do this, we will need to have a
set of data consisting of many photos with the appropriate descriptive
captions.
28
Applications of LSTM Networks (cont.)
3- Speech and Handwriting Recognition
4- Music generation is identical to text generation, where LSTMs can predict
the musical notes, not text, by studying a mix of notes fed into the input.
5- Language Translation involves translating a sequence of one language to a
similar sequence in a different language. Like image processing, an image-
based dataset that includes words and translations is cleaned first before the
relevant portion to build the model. An encoder-decoder LSTM model can
convert the input sequences into their formatted vector (encoding) and then
convert the translated version. 29

You might also like