[Music]
now we will be listening from dr. V to
ravichandran from MathWorks manglu he
will be giving you a detailed exposure
on neural network toolbox of MATLAB
so dr. Bachand Rijn can you hear me yes
can you hear me ma'am yes yes we can all
very well hear you I think you can start
now you can your introduction then about
something about math works and MATLAB
also and then warren oh thank you thank
you sure good afternoon everyone thank
you ma'am for the kind introduction so
uh as mom mentioned I'm the Java
chandran or you'll find me as Lakshmi
Narayan Ramachandran on LinkedIn or on
Google Scholar so I lead the education
Technical Evangelist team at math works
what do we do as a team we work with
educational institutes to ensure that
our students and faculty are able to use
MATLAB and Simulink and a host of our
other products effectively for the
teaching research projects and many
other things I work at math works India
matchbooks is a company that develops
MATLAB and Simulink and we've been in
the India market for around or 10 years
and mass works as a company has been
around for 34 years and we are deeply
rooted in education and you know a major
part of our you know user base is based
out of education and you're happy to
take I have this opportunity present to
true us by ni triple TR to talk to you
about MATLAB the neural network toolbox
workflow and tomorrow a little bit on
optimization so um I was told that I
have our time until afore PMR this
afternoon so we'll be going over a
little bit of the neural network toolbox
workflow in the initial part of the
session and this will be followed by
what has been a natural extension to
neural networks uh you know in the
recent past especially it's become a big
buzzword it's known as deep learning a
lot of you know what machine
is I'd like to show you what the
difference between machine learning and
deep learning is and then how you can
use MATLAB to do that if time permits I
will show you a few examples otherwise
I'll show them tomorrow
on the deep learning workflow and we can
get started with the optimization so and
I'd be happy to take questions in
between or towards the end of the
session and you know um of course I you
have you been exposed to this webcast
session for a lot longer than I have so
there are a few etiquettes which I think
uh man would have briefed you about so
that sort of gives you know provides you
with an introduction of me and what you
can expect from the talk I just want a
quick
you know I I'll open my hangouts browser
but maybe if you can unmute your lines
one by one and you're like how many of
you have worked on MATLAB or how many of
you worked on Simulink maybe I can a
couple of you tell me what you have done
using MATLAB or Simulink anyone anyone
from the CentOS sure if I'm not able to
answer your question or if I don't touch
upon those because today we'll be going
over a basic workflow you can always get
in touch with me offline and we'd be
happy to talk to you more on that my
email address is on the slide over here
yeah okay anyone else saw that and
descenders yeah okay I think many of
them are working I have not explained
them to a simile and MATLAB axis but I
think I hope that they are they know
yeah I will go over a brief I'll do a
brief
intro to MATLAB if needed do you think
that would be helpful our participants
just say yes or no a brief intro to
MATLAB and all that okay sure I can go
over that okay sure
good okay that that helps okay sure so
uh the talk today as I mentioned we
wanted to introduce what is an
artificial neural network I know mom
might have spoken to you about what it
is but a little bit of a background on
what artificial neural networks what do
we have as what is an artificial neural
network and what is there so in this
block diagram if you notice there is an
input and there is an output yeah and
the output is tested against a target
output and then you you provide some
form of a feedback here the feedback is
provided to what is known as a neural
network which includes connections
between neurons and these connections
are called weights what are neurons
essentially it's one of the simplest
elements of what is there as a cognitive
system you can draw parallels to a
control system which has feedback or you
can also draw parallels to an adaptive
or filter which also has feedback a lot
of times what happens is we want to
ensure that the output and the target
are so close enough that by adjusting
these weights the difference between
them or the error there is minimized so
that is essentially what an artificial
neural network is so it's an input and
output a neural network in here where we
are just a weights to be able to ensure
that the target is you know close enough
to the output or output is close enough
to the target yeah and the output is
produced based odd on the input and the
activation that is over there now what
happens is in this block diagram I
introduced neural networks as a block
now what happens is the neuron model
here is that you have multiple inputs to
the neuron which take into account a lot
of weights that is W 1 to W R ya and
each input you know if you have our
inputs each input is weighted with an
appropriate weight parameter okay and
the sum of the weighted inputs and it's
not only the sum but you also have a
bias that is fed into the transfer
function okay which is known as the F so
you have here which is the sum summation
each of the inputs with the weights and
there is some bias here which is fed
into what is known as the transfer
function a lot of you might be familiar
with what is a transfer function from a
signal processing perspective its output
over input of course in this case it's a
nonlinear transfer function for the most
part which is like an log sigmoid or at
an sigmoid or you may also end up having
a pure linear transfer function the
choice of this transfer function is
dependent on the user based on his
application and every neuron uses any
differentiable transfer function to be
able to generate their output yeah so
what do we have here the weights the
bias and then the transfer function so
we have our in our elements in the input
vector now what happens here is we have
a single layer architecture which
consists of the following parts that is
the input layer the weight connectors
which are there in a crisscross yeah and
then you have the summation followed by
the bias okay and then you have the
activation layer which is essentially
the transfer function and then finally
the output okay so this essentially
takes into account maybe what it might
be for a log sig function and things
like that so this is with respect to
each of these inputs coming in
separately yeah but MATLAB is a vector
or you know a lot of the inputs can be
vectorized you don't need to end up
writing for loops for each of the
vectors you don't know it's a MATLAB
stands for matrix laboratory so a lot of
you know that matrix multiplication is
simple so what we can do is we can
combine all the RS that is the input to
one particular vector which is also
their SP so you have R by one which is a
P and then W is essentially the way
to equate matrix which is say s by r and
you have the bias here which is
essentially b12b s which is also there
as a vector which is of course a column
vector this is also a column vector and
then when you sum it you end up getting
what the output is and that can be done
a fast transfer function let me try yes
so what we would sorry I think now you
are here yeah so what we'd like to do
ideally is to ensure that we set up the
problem in such a way that it's all seen
as a vector so you have R which is an
input vector which is sorry P which is
an input vector of size R the weights
which are of size S by r the bias which
are of size s by 1 which is a column
vector and the output becomes s by 1 and
which is password transfer function and
you get this as well so this is
essentially what the overall or we you
will pass it in MATLAB to the you know
in terms of vectors yeah because you
don't want to take each of these inputs
now this is a single layer architecture
what happens within a few layers you
know if you want to configure factors
within a network you can say I have an
input layer I have a hidden layer so you
will essentially see a few things in
terms of what the matrices are we'll
come to that this is I
w11 which is an identity matrix so
you'll essentially have diagonal weights
and then you have the bias or that is
there here similarly what the output
layer is so you have this as well and
what this will give you what this input
have what this network has is it has an
input layer with two inputs it has a
hidden layer with four neurons that is
for rates and for biases which is why
you see a four by two and a four by one
and the activation here is a dancing
Laer yeah and it's one line of command
here which takes into account W the P
that is the input and the B that's the
bias and you just pass it through that
that's my Eva and then the output layer
has three neurons which means it has
three weights and then has three biases
and I get the output as a three vector
and the activation is a pure linear
layer yeah so this is how you can
configure what the input is going to be
in this case one vector what the hidden
layer is which has four neurons and what
the output layer is which has three
neurons this is how you end up
conferring configuring the two layers
that is e1 and e2 in the form of two
particular lines of code yeah okay now I
want to draw your attention to what is
there in the documentation in the form
of other network architectures yeah so
we have a very very powerful
documentation very well documented set
of features within MATLAB and I'd like
to show you what we have here ok of
course I am in India so you can access
it from the web or you can also access
it from our you know from within MATLAB
so in this case I'm just defining the
shallow neural network architectures so
it actually shows what is a historical
and alternative so you have the adaptive
neural network you have the radial basis
neural network perceptron if you want
linear hopfield probabilistic any of
those let's go into the radial basis
neural network it shows you the same
thing that I had over here what the
neuron model is it says what the
transfer function for the radial basis
function is how does the plot occur the
rad mass transfer function I can zoom in
a little more and then you know it says
what is a neural network architecture
you know it says I have the input layer
which is of course the same the radial
basis here is of one particular unlinked
and the only change I have here is I use
the function called rad bass and the
linear layer which is essentially the
second layer here which is the output
layer over here and it gives me enough
information
on how do I set it up so the output of
the first layer can be obtained by the
following code what do I have here so
essentially I'm gonna say rad bass yeah
and I'm essentially gonna say take the
take the distance and I'll be sending
you this information but it's just as
one particular line of code which takes
into account one the bias then to the
input and what the value here is and
then overall take the net earth or
uniform the network and then use the
radial basis function yeah so in some
way you don't need to end up writing
these types of lines of code it's much
easier in some time you will see how
much easier it is to use the Brittain
functions or apps that we have but what
I wanted to show you is if you want to
understand now each of these is done you
only need to end up writing net equals
new radial basis over here B and I have
the target vectors that RTP is the input
vector T is the target vector and spread
is the spread constant which is for the
radial basis layer yeah and it creates
many neurons and you know it ends up
showing a lot of things that are seen
here as the output but what I would like
to just emphasize here is it's one or
two lines of code that you need to use
you don't need to end up writing a lot
of code and this is why we end up
positioning what is known as a neural
network toolbox for neural networks of
course you can write your own
functionalities but once you or the
students have understood what um you
know the concept behind neural networks
is it's easier for you to use the
built-in functions of course when you
teach them initially when you teach
students or when you're trying out do
not use the functions because I believe
that if someone just uses a
functionality and does not understand
the background behind the functionality
there is no point and most of us are
educators here who would like to ensure
that the student understands ik concept
yeah so that is another thing so so
we'll be looking at the radial basis or
neural networks over here so the radial
basis function
essentially what we do is it has a
radial basis new on the transfer
function here is rad bass of n which is
represented this way which is the radial
basis function it has a maximum one when
the input is zero and when the distance
between W and P reduces the output
increases okay and there's more
information on what the radial basis
neuron does as a detector and what the
bias does with respect to the
sensitivity and all that and I'll be
passing on these slides to you as all
you know after the session so this is
something that's there in the theory of
the radial basis noodle network yeah now
what I want to show you is a couple of
examples as mama requested on how you
can use the neural network toolbox the
built in apps and all of that stuff but
before that I want to go over the
workflow so I'll come back to this in
just a little bit this example for a
time series or or or time delay neural
network but I wanna point out the
workflow for using neural networks can
someone tell me what would be the first
step in using a neural network a first
step in any mathematics problem awesome
and I'm so happy that you said because
I'm so happy that you didn't tell it was
the algorithm it's typically what we
need to collect us data that is the most
important thing the next step is to
create the network yeah and we will take
into account a lot of criteria when we
need to create the network next what we
do is we need to configure the network
you know we'll need to see which is the
algorithm that would go and behind and
creating the network you would say how
many layers you need when configuring
you might need to say what does a
minimization think that you need to do
or what algorithm you might need to use
and then you initialize the weights and
the biases because it's not going to
work right away in the first instance
yeah and then you end up training the
network can someone tell me what this
training process means why would you do
that
[Music]
any other answer over all why would you
need to perform any form of training on
a data set so then it should behave yes
or the algorithm behaves the way you
want it to you give it sample data and
you say that this is me this is a ground
truth ensure that you adjust the weights
in such a way that if you end up finding
similar data ensure that you classify
properly that's in the classification so
not you write the same thing over here
as well we want to ensure that the
network is trained because we want the
target and the output to match as much
as possible so that will be the training
process following that you will validate
the next book what what do you mean by
validating the network you would have
set the weights you might be giving new
data yeah the old data was used to train
but you might be giving new data to
validate the network and then see what
the error coefficient maybe is and then
finally you use the network is this
clear to everyone of you like any
questions on this front this is the
classic statistics workflow you know it
need not be just neural networks it can
be for any classification algorithm
except that in that case it may not be a
network it will be the choice of an
algorithm choice of the parameters and
then training the classifier and
validating it so any questions at this
point of time on this workflow ok I will
assume that you know or the answer is no
I have a few screenshots on what will be
the process but I will also be walking
you through each of them our neural
network our classifiers that are over
there
so before that I want to say how do you
collect data so the key thing which is
very nice about MATLAB is that you are
able to access data into MATLAB in many
ways it need not be just a mat file it
can be from an excel sheet it could be
text it could be binary it could be
audio/video files images a lot of times
now there are images that need to be
classified or images that need to be
trained so deep learning is very very uh
you know um useful in computer vision
problems we'll take a look at that in
just a little bit
you also can read from scientific
formats like extended markup language
you can read data from multiple
databases or from other languages or if
you have measurement hardware like say
um you know if you need to acquire data
serially or you know you store it and
afterwards you take it in you can do it
using what is known as the data
acquisition toolbox or the instrument
control toolbox yeah now so MATLAB as
such as I mentioned there is something
known as apps which are over there I'll
just show you a bunch of screenshots and
then we will walk through the whole
process right away so you need to you
you have an app which I'll also show you
in MATLAB you have an app which does the
neural network start you can choose what
sort of a thing that what what sort of
an application you need to perform in
with respect to neural networks next you
end up getting say if you're looking at
the fitting tool you may get a
screenshot like this and it says you
know what are what is a what would why
you need this and what is the neural
network wouldn't look like and then you
can select data and I'll show you in in
in the next few minutes on how you can
load data I might use a example data set
and after which I can select you know I
can partition the data for training and
validation if you realize we mentioned
that we might need to train a little bit
and then validate it and then test it so
we split it up in such a way that a lot
of data is used for training and some is
used for validation and some is used for
testing yeah and then you can define the
basic network architecture we'll come to
that and then choose a training
algorithm I'll come to that also in just
a little bit you can you have help
documentation in every component at this
point of time and there are multiple
training algorithms that are over there
starting from a basic gradient descent
to say or the Levenberg Marquardt model
or you can define your own training
algorithms as well so you have support
from existing algorithms and also
are you know from but your own user to
find our training algorithms the overall
learning workflow which I want to point
out is you iterate till you find the
best model that is you have your data
you pre-process the data in whatever way
you want you may be able to perform
supervised learning class of
classification regression and get the
model this is an iterative process okay
in the prediction what you end up doing
is you have the new data
you take that pre-process thing and you
take that particular model and are able
to predict it so the training step is
very very important in this case okay
and of course you have the option of
evaluating the network we will come to
that in some time and then finally be
able to generate MATLAB code or Simulink
model automatically ok so I want to go
back to the same I want to go back to
that set of things where we said what
each of the things is so we will collect
the data create the network configure
the network initialize the weights and
biases strain it validate it and use the
network yeah let's switch to MATLAB for
the next ten to fifteen minutes I'm
going to be using MATLAB oh you know
just so that you're able to see what is
being done I'm not a very big fan of
only using PowerPoint slides so I prefer
using up moving here okay
how many of you are familiar with this
setup of MATLAB can I have a you know
show of her or rather can people tell me
what's a version of MATLAB people are
using 17b here you see in our Institute
also we are using 14 okay and any other
answer any other centers okay sure so um
every year there are two releases in
MATLAB so one of the releases is called
2017 and the other release is called
2017 this year in in another two weeks
there'll be a release called or in a
week there'll be a release called our
2018 a
and in September you will have a release
called our 2018 B yeah and there are
updates to the functionalities and
features especially the neural network
toolbox had a huge you know change in 17
a and 17 B because neural network again
got a lot of attention because of deep
learning because neural networks was
almost branded as a dead area like in
you know the early 2000s but in the last
four to five years there's been a lot of
you know um interest back in neural
networks will see why that is that's
because of deep learning and we'll see
what the reason for that is when I
switch to the deep learning deep
learning topic but what but the reason I
asked you is in in 2012 B that was
around five years back we introduced
this tabs here at one of the tabs here
is called as the apps okay and if you're
not able to see it let me try to change
my display setting to ensure that people
are you you are able to see
I'd like to ensure that all of you are
able to see it
is this better yes okay so you see
something known as apps and in this apps
if you notice I have marked a few
favorites here which has curve fitting
distribution fitter optimization I
created my own app which is called our
you know NEC app I'll show you what that
is I can show you how to create an app
later in the match starts an
optimization you have like multiple apps
which is neural network clustering or
neural networks fitting neural net for
pattern recognition or your neural
network times CDs yeah but let's not do
that and let's start with something else
that I have the way I do is I just type
neural network start yeah and then start
can anyone tell me what I might get here
has anyone used this you have used it
okay sure
now in this in this you can see what the
you know more information is you can see
what the examples are or what the data
let's go and take a look at what these
okay this seems to not work with in
terms of clicking it opened so if you
notice it it showed you know there's a
lot of datasets that's already there
there's some body fat our dataset or
chemical data set let's look at what
this body fat data set is is you know
it's body fat percentage data set so
essentially it loads are you know around
arm it loads to variables which is
essentially for 252 people 13 parameters
that is their age weight height and
multiple things about their body yeah
and then essentially I have the target
which is essentially going to be
estimated from the input what are the
body fat target is it has here I have
all these circumference a height weight
and everything and I need to get what
what the body fat target is so I can I
can get what data sets of ants or what
the examples are and things like that
okay now shall we take maybe an example
of the fitting up initially so you can
type an ft tool if you want or I can
just click on that okay who can tell me
okay let me try to sorry I don't mean to
do that
okay okay unfortunately I'm not able to
see the few of the buttons that I need
to see i'm unfortunately gonna have to
reset my display thing to a little
lesser because it doesn't seem to show
but if an if in case you're not able to
see please do let me know okay you able
to see it still yeah okay so if you
notice here in zoom in sometimes so so
if you notice over here it says of
course welcome to the neural network
thing i it will say examples so this is
a neural network so all I need to say is
next yeah and you can get the data from
workspace of course I don't have any
data which is in the workspace okay and
what the target is so I'll say load
example data set
we said we'll look at the body fat
example so we are essentially getting in
a 313 by 252 matrix which essentially
takes into account all of these for 252
people and what the targets which is to
be estimated from the input so I'll
import it okay
and if you notice in terms of the input
it's essentially body fat input data
would check and in terms of output I'd
say body fat target I can either say the
samples are rows or columns so let's
take a look so what is it here in this
case yeah so essentially we will end up
saying that it's it's there as you know
because it's a particular row we'll say
that each of the column has has the data
for one particular person yeah so it
says 252 samples of 13 element and 252
samples of one element we essentially
wanted for one element if we say the
other way round it will say 13 samples
of 252 elements which is wrong so we
wanted the matrix columns okay next I
will go to next okay
now can someone tell me what is
happening in this setup here so I have
the thing where I need to choose some
for training choose some for validation
choose some for testing can someone tell
me what's going to happen there may I
have a question here what yours
invalidation interesting why don't you
tell me what's the validation thing
where we do not know what the answer is
okay given are you able to read this
statement here what is there below
validation they have no effect on
training and so provide an independent
measure of network performance during
and after training not as testing can
you read what is a validation to measure
Network generalization and to wall to
training when generalization stops in
going okay so when so even though the
training is done the validation will
ensure that if there is Network
generalization if it's not improving it
will stop it over there okay so
validation is to ensure that you're
trained training process because
is gonna take a very long time correct
and we want to ensure that the training
is in a mode where the input oh sorry
the output and the target are matching
if they don't match we will not be going
so the validation is essentially where
we test other output against the ground
root to say that hey yes it's working
fine go ahead and train more data okay
now I can go and change it to say
validation as 5% and I'll say I need 25%
of testing the default is essentially 70
15 15 let's go with this but we'll
change it in some time okay
we'll maybe reduce the training thing
and we'll we'll see what the effect is
so any questions at this point of time
okay next I'll go to next and I'll see
oh you know define the fitting Network I
will say what is a number of hidden
neurons okay so if you if you recall in
my arm sorry not here in my thing I
should be able to say how many neurons
do I have or in this case I should be
able to say in this hidden layer what it
is going to be what that n is going to
be are you okay with ten or do you want
to change the number or we'll come back
and take a look at what be what it might
of how it might affect we'll do that
afterwards let it be 10 at this time now
what I do is it it also says
recommendation return to this panel and
change the number of neurons if the
network does not perform well after
training so it's obvious now I go next
and I can choose a training algorithm
there are three of them that I can
choose for this particular example but
as I mentioned there are many many of
those that can be used which is shown in
this particular slide so if you notice I
can choose many many of those algorithms
in this training component okay now let
me choose a default one and what I will
do is I will say train okay so this
Levenberg market algorithm says it
requires more memory but less time and
the training automatically stop stops
when the generalization stops improving
okay or if I want to say Bayesian
regularization it will say it requires
more time but can result in good
generalization for small or noisy data
sets it's essentially shows what it is
and it also says you can train multiple
times but then it will end up generating
different results due to different
initial conditions and sampling okay now
let's train it and what I got
immediately was a network that was
trained like this how many inputs do I
have here 13 and what is the number of
hidden layers then and the output is one
how many iterations do you see over here
it says around six sixteen iterations
okay and I'm able to see how many
validations in it perform six of them
and all six of them are correct so
they're the generalization actually
reduced yeah so I can go here and check
what the mean square error is or the
r-value is it's it's in some format it's
say point eight two or point eight eight
for the training 0.86 for the validation
and point eight two for the or testing
and here the a mean square error is also
there in some format now let's say let's
plot the fit okay this has more than one
element so it doesn't okay plot the
error histogram okay so can you tell me
how should the error histogram look what
is a what is error essentially should it
be a target minus output is that correct
and that error should be close to zero
through more the number of values closer
to zero this yellow thing is zero more
the number of values closer to zero it
means it's a better fit this should
ideally be tapered down over here okay
so of course there are values here but
there are things with more errors yeah
and if you notice the Train it was a
training thing but with respect to the
test of course we had a few values here
but there are errors that are occurring
with a little bit of higher magnitude of
error as well okay now you can also plot
the regression value which will
essentially end up showing
you what it is you know with respect to
the tar this is the fit this is the data
so if it lies on the other side it's
correct if it lies on this side it's not
correct so you have those sort of
parameters that we need to take a look
at so you have all of these plots let's
go back and change a few things what
would you like to change here number of
neurons so shall we change it to maybe
16 or or maybe let's change it to 32
we'll see how that is and then let's go
to next and let's train okay now how
many iterations did it take right now 12
as opposed to how much did it take
previously being 16 and is the error
here
you know the R value closer to 1 is
better yeah and let's plot the error
histogram is it much better yep closer
to 0 do you see more values yeah and
there are not too many with too many
errors so this should essentially be
where we need to have a lot of values
yeah now let's maybe take a different
regular maybe Bayesian regularization
algorithm and let's retrain and we did
say that it takes a lot of memory and
hence it also is time but they may be
more accuracy so the Bayesian thing
essentially says requires more time but
can result in good generalization for
difficult small or noisy data sets and
the training stops according to the
adaptive weight minimization so it still
is doing a lot of iterations it still is
trying to see what it is what the
parameter is changing and if you notice
the MU value is changing between point
zero zero five to one so it does take
considerable amount of time yeah but it
can result in a good generalization so
you are also able to track how much time
it is taking say if in case you want to
report your findings in a research paper
you can say on MATLAB our 2017 P on an a
GB or a hard drive or a GB ROM this is
how much it takes so how many iterations
did it take here
741 but let's take a look at what the
value what the error value our value
here is 0.89 and we do have the training
MSDS let's take a look at the error
histogram yeah so you do see that there
is um there is more error that is spread
out but it is still contained within
plus 10 and minus 10 yeah so it's it
depends on what your parameters are and
how many do you how many or new neurons
do you have and things like that so it's
up to the data that you have which you
will need to select how much you want to
be doing training on how much do you
want to be doing validation and how much
you want to be doing testing on now I
want to show the effect of maybe
reducing the training data set and let's
increase the validation and testing some
how much how many samples am I using
here for training 45% as opposed to 70%
how much am I using it for validation 25
and around a 30 let's go and check what
happens here and it's going to be around
10 hidden neurons and then I'm gonna use
the same Levenberg market algorithm now
let's check what happens did I have too
many iterations for the thing for the
training no it was 13 why because my
training data is lesser is that right
yeah and now let's see the error
histogram is it more significant is the
error more significant compared to what
it was earlier yeah because the training
data is lesser so unless your training
data ends up having the best possible or
all cases it may not end up giving you
the best performance okay now let's go
back and change it to a point where will
reduce the validation so it's a 10% this
is now increased to 60 percent let's go
and check what happens again yeah I'll
train it and when I plot the errors
histogram it's definitely include with
the minimum error you know lying between
minus 9 to 11 in the previous case it
went on to 40 and a few others
even though it looks spread out we are
doing it in terms of bins if you
realized yeah so this is essentially how
you can perform to overall training of a
network and then also end up validating
it and then finally are trying to see
how the classification works now when
you go next over here
you can evaluate the network okay you
can perform additional tests if you want
on data or you can adjust the network
size or you can import a lot larger data
set or you can say train again and few
other things this is optional after that
you can get an application deploy
solution what is the first thing here
what does it say here
MATLAB function so it will essentially
end up creating what is a built-in
MATLAB function so it essentially says
it's my neural network function where X
is my input yeah and I'm not giving any
outputs and what are the outputs or any
other additional input what are my
outputs I end up having you know my Y
which is the essentially what the output
value over TS time steps is I ended up
getting what my gains and the offsets
are that is a bias and the offsets what
is the number of layers what is a bias
in each of the layers if you notice that
is layer one and layer two and then what
are the I and L values and then what my
output layer is and how do I simulate it
the all of this function was
automatically or general all of this
function was all automatically generated
is that helpful when you understand the
neural network work so you know MATLAB
all you need to do is ensure that you're
able to train the parameters
appropriately you know train the
parameters well so it says it uses a
sigmoid transfer function so there
multiple things over here so these are
the module functions which are there so
this code is automatically generated by
the neural network toolbox now the
second thing is if you want to deploy
you know it into see an executable yeah
if you want to or generate a C code yeah
you can just get a matte matrix only
function because the previous one
actually had a cell array so here what
you can do is you can get an executable
using MATLAB compiler yeah it will give
you an exe but if you want a C code you
can just get a matrix only function the
next thing I wanted to show you was what
does this Simulink equivalent model of
this look like so for the first time it
takes a little while for simile to open
up because it's generating the model and
Simulink is a pretty heavy platform with
a lot of toolboxes and you know the
blocks are corresponding to each of
those toolboxes and what do I see here I
have an input X I'm an output Y and at
the function fitting I get I can double
click on it and say it's a mass it's a
function fitting but I can go in I can
say right click it does my computer's a
little slow apologize can go and say
mask and I can say look under mask it
has two layers ok and one of them is the
input layer which is going in here which
is the first layer and the second layer
which is the which is so we have a two
layer Network and the output layer let's
take a look at what the layer 1 looks
like we'll do mask and look under mask
again so I have the D list I have my
initial weights and the bias and I have
the transfer function let me go look at
what this is a tan cig function let me
go under mask and say look under mask it
essentially shows me what the overall
thing is you know it says minus 2 e
power u plus 1 and then reciprocal of
that plus 2 and all that yeah it's a
pretty straightforward thing let's look
at what's under the weights it we go to
masks and we say look under masks if you
notice it essentially has a weights
function or away it's block for each of
them I can look under each of them
and actually I cannot because it's
something that will show me what the
constant value is so this essentially
takes into account what the weight here
is for each of them you know like the
ten particular weights that are there
and for each of the layers so this is
for one of the layers one of the weeds
okay and the overall function fitting
here the layer two here will end up
having ten more of those so let's take a
look that bad and I look at the mask I
have the same and here it's a second
weight and I look under mask I have a
similar thing where this a set of
weights the input here and then what the
overall output is going to be this
particularly I like Simulink in this
case because it gives a very visual
representation one because a lot of
times if you notice when I started out
my presentation itself I started out
with this sort of a block diagram if you
realize or you know with this type of a
block diagram and what you get and
Simulink is pretty close to what you
have as a neural network in literature
so it's very helpful to be able to see
what pictorially it represents students
are able to learn better you are able to
explain it better to in your research
publications and more importantly you
can have streaming data coming in you
not using your data acquisition devices
and you can set the time to say infinity
and as the data comes in you'd be able
to you know provide the output and it
can function in real time and you can
also just get a basic graphical diagram
of the neural network which is a general
thing you know if you want to just put
it in your publications you can just end
up are saying this is what I have my
function look like okay the next part
but this is what my overall neural
network looks like yeah I'm sorry how do
this display solution I just clicked on
neural network diagram okay so all of
this is contained within that new neural
network n n start okay I'll go over it
again for another example but at this
time is the workflow key
yeah okay now I'm gonna go next and you
know it C is do you want to save a
result you know save it to the workspace
and all that stuff you can do any of
those at this point of time I'm just
gonna close it I'm not gonna bother
seaming it okay now what I would like
you to do or explore is next or what we
would like to do is next maybe look at
what it is for a time series dynamic
time series yeah so what is a time
series here can you can you tell me what
can you tell me where time series
analysis is important any answers I can
get to answers anyone what's it why is a
time series analysis is important
because time series is a pretty
important term in these days so any any
response why would you need to perform
time series analysis some sort of a
prediction can you give me an
application stock exchange great so that
is one yeah definitely so the thing is
say for instance if I can if I want to
see you know over the year I've seen
what or data I have you know maybe I'll
say one of the airline's wants to take
into account what the delay was with
respect to a particular aircraft you
know over the over the over the years
and say in November Delhi has fog or
Delhi has a you know
fog in January also that contributes to
a delay in Bangalore because they're
coming incoming aircraft is from Delhi
can be routed elsewhere so they're able
to predict it by ensuring that they
learn the model initially yeah so as it
is mentioned your prediction is a kind
of dynamic filtering in which past
values are used to pray
the future values okay and dynamic
neural networks include either a tabbed
delay line for nonlinear filtering
applications so you can provide a
feedback or it could just be a thing
based on what the past values are okay
so let's take a nonlinear input-output
you do have a nonlinear orto regressive
with some extra external input or
non-linear autoregressive with no
external input let's just take and walk
on nonlinear input-output these
predictive models are used in say you
know this predictive maintenance of you
know systems like say a jet propulsion
engine may not know you may not know
when it is going to go bad so if you're
able to collect the data and say at this
time we should perform a maintenance
check they can definitely be a lot more
savings involved rather than going and
checking every time yeah so in a lot of
chemical processes robotics or aerospace
systems manufacturing systems it is used
now non-linear input-output time series
analysis okay I will load an example
dataset again so what I'm gonna do is
I'm gonna take into account
maybe pollution mortality okay so what I
have here is I have the pollution input
so which essentially says what is the
temperature relative humidity a few of
the harmful harmful gases ozone and the
particulate matter okay and then I have
the pollution target which will
essentially say what is the total
mortality respiratory mortality that is
how many people may end up getting
respiratory disorders how many people
end up getting cardiovascular disorders
is this a good data set is that okay
with you guys okay and I have 508 cell
arrays with eight by one vectors for
each of them so my data has 500 data
points or 500 time steps so I'll import
it so I have the pollution input and I
have the pollution target okay now as I
said it's a 508 hour time steps of eight
elements it's gathered over five hundred
and eight time steps now let's go next
okay I use the same thing I'll use
around what do you call
you and you in interestingly in this
case what has happened is you end up
having what is five hundred and eight
times three it's gonna be fifteen twenty
four yeah you need to end up getting
fifteen twenty four tiger time steps so
essentially end up taking around seventy
person for training and remaining for
validation and testing as always let's
go next and here what you can also in
terms of a time delay why do you need
this time delay is you need to ensure
that how many time steps can the network
respond to how much do you want to go
back in time yeah and the number of
hidden neurons is ten we will change
this parameter you know how is the
output how many times is the output a
function of the input and things like
that you'd be able to say that that's a
delay if you want it by off the only to
be t minus 1 and t minus 2 this will be
2 if you want it to take and talk on
many more like it's almost like an F IR
filter or an IR filter with how many
previous samples do you want ok any
questions so far so P increase the delay
is what will happen the increase at
belay you will end up having more more
delays and you will end up getting more
data to make a decision yeah because if
you notice your your wife will be a
function of more data points now let me
change it back to two at this point of
time and then say I'll say next and I'll
use the same model and let's perform the
training it again took around 16
iterations there was some gradient there
was some validation check yeah and let's
plot the error histogram and of course
you know you see that there is a lot of
concentration around zero which means
the data is correct and we are getting
lesser error yeah and yellow bar there
indicates a zero error let's plot the
response yeah so if you notice here it's
a time series thing so my error is a
yellow one okay and I have the training
target represented in blue and the
training output represented in a blue
plus the validation and this one so the
overall thing here the black one is a
response and when you look closely let
me try to zoom in okay so if you notice
here I do have the response which is in
this way and it essentially connects
what my training output is and in a few
cases you see that the error is lesser
in a few cases you see that the error is
more and that's because we need to be
checked what the validation target or
the test target were so it was mixed up
in in a lot of these cases but overall
if you notice the target minus output
most of the error is less than twenty
here and which means the classification
is pretty decent now we can also say
plot the error autocorrelation so closer
the error autocorrelation is to this it
means that it's a better a of course
this has to be the maximum value in this
case if you notice a confidence limit of
it's around say 8% it's around 8% in
this case or around 8 and this is with
respect to lag depending on how much
delay you end up have it okay now let's
go back and change the number of delays
so let's change it to maybe four okay
and let's say next and I'll use the same
thing and if you notice over here around
eleven iterations were sufficient there
were six validation checks let's plot
the error histogram and if you notice
here it's a lot better now you know I
have around 500 data points in the you
know close to zero bin and around 400
data points you know with flow again you
know less than -3 or less than minus 4
yeah and here it's almost zero here and
let's say the error autocorrelation it's
a lot better you know as the value
changes it's a lot better and I don't
have too much of an okay so same thing I
can go next I can adjust the network
size I can import a larger data set if
m1 I don't want to do any of those I can
say I want a similar diagram or I want
an you
diagram it essentially should have a
delay element the weight and the bias is
the hidden and this is our output layer
okay or I can generate a MATLAB function
if I want okay so this is one of the
things that we wanted to show you man
wanted you know please yes
you just told about the time series yeah
functioning how can we make the
prediction through the tool box could
you just explain that prediction
prediction in the time series app how
can we make that actually the time
series toolbox has made it its own
output on the basis of the input and the
target yes if I want to get this load
the data then how will I mean for that
okay let me take a look at that I'll
take the same example okay and I'll go
next I'll do the same thing and I will
end up doing that I'll train and I'll go
next now you can say you know you want
to perform additional tests or you want
to take a look at additional data you
can lower that in here as an input and
then say you want the output to be
stored here and you can either perform
the testing of the network or you can
perform the classification right here
itself okay or the other thing is if you
want to predict the better way would be
to create a MATLAB function this way and
give the input here for the prediction
and you'll end up getting the output
here doesn't make sense so essentially
use the end tool to generate your
network and then either take a semi link
model or a MATLAB model and provide the
input here and get the predicted value
okay
we're in the Similan diagram so I can go
to similan here and it will end up
creating so here instead of the constant
you can end up giving your input
yeah so definitely you can go and say
edit match in this case it was different
inputs and all that over here but you
can end up giving your input over here
okay all better
in in do it using the MATLAB function
where you can give your input as X okay
okay but what if like I have got 120
points and I want to get the 121st point
then how will I get on to it I have the
other values I want to get further for
example for the next five days on the
basis of the past hundred days so how
will I be able to enter that five days
able to predict the future data yeah
sure so in that case what you can end up
doing is you end up pain you do have the
X put the luck put the last she was 0 at
this point of time okay and then see
what you get it should work that way
otherwise you can also use the fitting
app where you might have you might have
generated a neural network for this and
then you can put that in as an input and
or take the prediction I will send you
the workflow on this when I send you the
similarly you have the same
functionality for the pattern
recognition app and for a clustering app
so I'm happy to either go over this or
I'm happy to move on to deep learning
for computer vision problems and take a
couple of applications there whatever
works for you it's a similar wrap map so
and we can send if we can send them how
to get how to you know maybe a couple of
examples which are there we can send
them that example looks okay now also
mom will we be able to get the email
addresses of the
depends to be able to send the thing
I'll talk to you about that but we would
like to send them I have the email any
of all the coordinators of the centers
who are so I can give that to you
awesome them and then they will send it
they will send it on their own
sure definitely thank you ma'am no the
thing is the next thing I would like to
talk about is deep learning for computer
vision applications using MATLAB for the
next 40 minutes I'll go over basics of
deep learning and why did it gain
importance and maybe two examples and I
will go over the third example tomorrow
when we are talking about the next part
okay so agenda for this talk is going to
be what is deep learning why deep
learning and we'll go over a few things
based on how much short time we have
okay can someone tell me what deep
learning is someone from the audience
someone from one of the centers good
so essentially learning is about
automation and you know we want to
ensure that we don't instruct the
computers on what to do but instead they
should learn on on their own that is
enabling them to get some artificial
intelligence so deep learning is based
on the neural network architecture that
is a computer system architecture of
human brain and nervous system the term
deep refers to the number of layers that
is neurons and rules in the network more
the number of layers deeper the network
at this point of time if you notice
there was one hidden layer and one
output layer but if there are more
layers its the deeper the network okay
and deep learning is a type of learning
in which a model or a computer or any of
those networks learns to perform
classification tasks directly from
images text or sound yeah so a lot of
you might have noticed
yeah when you're able to put your photos
on Google photos or Facebook or I photos
it can say it will detect the face not
only that but will it will say is this
this person is it this person yeah how
did it do that it's it has learned and
now it is trying to validate yeah on
what it is and it will say yes in a lot
of cases it does it automatically and
then you know you can give it feedback
that it is correct or not what are a few
of the applications so there's going to
be a video playing here if it doesn't
help it if it doesn't play really well
do not bother I can I will be showing it
to you or I can send a link to you so on
the left hand side I have a green part
and I also have a blue component and the
green component there keeps changing and
you know it's sort of labeling something
as blue component and then it's showing
some it's trying to see something else
in terms of what is happening or in the
picture can someone tell me what's
happening here did the video play fine
no yeah okay so essentially what's
happened is you try to detect the blue
objects as objects that are moving okay
green as the navigatable path
it's an autonomous driving system so
it's trying to perform segmentation but
it is using a bit of semantics or a
little bit of intelligence in trying to
make a decision because it knows that
the blue vehicle is moving yeah or it
will move sometime it also notices that
the road is which it has you know for
movement is quite big and in a few cases
it's also misclassifying it I'd like to
do this second example where it's trying
to detect you know a vehicle with a
confidence of one saying it is a vehicle
in a few cases here if you notice it
detected something else is a vehicle but
it's not but in most cases it's able to
detect the vehicle when it is trying to
change lanes such that it does not
collide okay
so how did this happen this is
essentially happening where the
application or the network learns on its
own
learn to classify that this is a vehicle
this is not a vehicle this is not a
navigatable path okay now in a lot of
applications say in terms of
classification of a highway scene or you
know in a few cases you might have a
video which has some fog or rain you
might need to remove it or you know a
lot of times you have the human
awareness on for robots where we need to
ensure that the robots essentially are
aware where the humans are and don't
collide with each other so you need to
say what bear the humans are and things
like that okay so I want to talk about
traditional machine learning and then
what is deep learning can someone tell
me what do you mean by machine learning
anyone to train the machine okay you
perform it specific task
okay anything else okay to make the
decisions okay let me ask you this I'm
assuming a lot of you either as kids or
or now who may have kids do end up our
teaching your kid different shapes and
all that yeah so let's say we wanted kid
to be able to identify triangle square
or you know a square circle and all that
stuff yeah so for him to identify him or
her to identify the shape what would you
first or tell them would you ask them to
look at the number of sides yeah and if
it has three sides it's a triangle if it
has four sides is a rectangle or a
square or a rhombus or a parallelogram
so a circle means infinite number of
sides or it's round Pentagon but now
when it is a square when it is four
sides how does it know to classify a
square or rectangle you will say take an
additional feature which is length of
the sides or the angle yeah so see if
it's a rhombus and things like that so
those are known as features and these
are handcrafted we specify we tell the
kid to add you know that look at the
number of sides then look at the
of the side look at the angle between
the sides we tell that the feature
extraction mechanism is something that's
that that the kid does the way we tell
it to yeah these are handcrafted
features after that it performs that la
ossification where there is machine
learning okay so that is traditional
machine learning where the features are
handcrafted and it sort we tell the
person on what the features that need to
be extracted are in deep learning it
performs end to end learning by learning
the features representation and the
tasks directly there is no handcrafted
Ness over there it will essentially
dwell into what are them what are
different layers which you know are
taken different features or which
represent different features and learns
automatically okay and then it is able
to identify what it is okay so we do not
give it what features it should be
looking at doesn't make sense yeah so
essentially the kid if it's not told
what the shapes are and all that stuff
and it looks at it on its own and
assumes that hey it has four sides now I
know this so if it's able to learn on
its own it's one that's deep learning
everyone feeling with this workflow or
this understanding okay great so the
end-to-end learning and the feature and
learning and classification are all
performed within the network itself we
do not help it with the feature
extraction now why deep learning why did
it gained so much prominence and the
recent past so in the beginning of this
decade what happened was machine
learning had almost an error of say 30
percent or 25 percent yeah but then in
the last few years deep learning
algorithms which got or reintroduced
thanks to neural networks or new neural
networks which got reintroduce thanks to
deep learning has surpassed the human
accuracy human accuracies around 7.5
percent in terms of classification
they've surpassed the human accuracy but
how did that happen
yeah and this is essentially four there
were a few imagine there's a database of
images called imagenet and we were
looking at what the
top five errors over there are so what
are the deep learning enablers so a lot
of computers have come with GPU nvidia
graphic processing units or different
graphic processing units so essentially
there's been like almost 60 times faster
training in almost less than three years
okay and you have labeled public
datasets say like you you all know off
capture that is like say if what you
need to enter to be able to validate a
transfer you know to be able to validate
a transaction the capture is a labeled
public data set because you are entering
and it will try to see what the value
over there is or what the text over
there is and then there are different
types of world-class models which
already have pre trained say Google net
or Alex net already has a set of images
that are pre-trained okay and you have
around say 20,000 images which are
already labeled oh you know around 200
categories and things like that or or
there are models which are there and
these have served as a starting point
for deep learning okay and typically
what we like to see is where does deep
learning fit into the engineering
curriculum because it's an advanced
concept so perhaps you know you look at
undergraduate courses in image
processing or computer vision or on
neural networks or you know a course on
adaptive signal processing or methods
for autonomous design please do reach
out to me if you want to work on any of
these we are more than happy to support
you on that now what I want to do is
just just show you five lines of code
okay for deep learning okay so I'm gonna
go back to my MATLAB and I'm gonna open
okay now what I'd like to show you is
essentially five lines so I'm gonna sort
of have this on the side here and
perform the same actions just so that
you are able to see what I'm doing okay
so let me
um minimize this let me also minimize
this and let me minimize this one okay
okay so the first step I'm going to be
doing is net equals Alex net okay
so what I'm doing is I have a
pre-trained model okay and MATLAB is
able to access it for me or internally
from an add-on Explorer I'll show you
how to do that I can say net equals Alex
net and when I run it it essentially of
course it says it's busy because it's
trying to load it what do I have your
net equals its it has layers it's a
twenty five by one neural network with a
convolution neural network we'll come to
that okay next what I'm going to do is
I'm going to read as an image which is
already there in matlab which is peppers
and I will store it and what is known as
an image one or something okay so when I
say I am sure of image one essentially
is capsicum okay it is capsicum which is
known as peppers in other parts of the
world okay now all I need to do is I
need to resize the image such that it
fits into the Alex Nets our framework so
I'll say image 1 re resized equals I am
resize of I image 1 comma I just put in
the okay and then all I need to do is
one line of code to say what it is so
label equals pacify equal network that I
have defined an Alex net and pick the
image that is resized okay and it
performs a classification and what did I
get the classification as well okay
which is essentially what it is and then
I can this is essentially what it is and
it gives me the right in at the right
example
or the right answer for this particular
example yeah so how many lines of code
did I write can someone summarize what I
have done in these five lines of code
what is the first step
new neural network choose the pre train
model and then what am I doing here
reading the image and then displaying it
and then resizing it the only line of
code is what I am writing is classify is
that correct
okay so essentially what I used here was
what is known as Alex net you have
multiple other networks and the way I
can get that in MATLAB is go in to the
home and I have something known as
add-ons and I can say get add-ons while
that opens up I will tell you so these
add-ons are something but both math
works develops and third-party
developers and user contributed people
develop like it's like file exchange but
it is within MATLAB and I can go and say
Alex net okay and if you notice over
here it says neural networks toolbox
model for Alex net yeah and it's a math
ox feature
it contains pre-trained thing and in my
case it is installed I can also end up
saying Google net if I want and google
net of course there is something that I
have here neural networks toolbox for
the Google net I don't have it installed
all I need to do is go here and then say
install and it will end up installing it
and it says it's functional for our 2017
B and beyond okay now so you're also
able to import models from other
frameworks so if you notice was it just
one line of code that I mentioned and
that'll be the same thing even for say
Google net or many other things and if I
want to import the models I can just say
import Kiera's layer or input the tensor
flow Karros model layer Kara's Network
any of those and you're able to download
from within
MATLAB yeah deep learning as I mentioned
uses a neural network architecture
there's an input layer hidden layers an
output layer in the previous talk in the
previous saw or topic when we talked
about the hidden layers was one in this
case it's n number of hidden layers okay
so I'll go over what this convolutional
neural network does is but the problem
the only the problem statement
essentially is the input and we need to
get the output we have the feature
learning and then we have the
classification that is being done who
learns a feature the network's learns a
feature who performs a classification
that's also done and it's completely
automated ok so any questions so far so
it is like that we should have a network
full of pre-trained you make this then
we'll be able to do yes or you can
create your own pre-trained images also
we will be talking about that do or you
can you know like use the pre trained
thing but then add your own layers as
well they will come to that as well so
now what I want to show you is a you
know a new feature in MATLAB which is
known as the live editor or the live
script so what I'd like you to see is
this so if you notice here I have the
same thing if you notice I have the same
text that I had before but here I have
what is known as the code and then I
have the classification and I of course
it says there's some error here or and
we'll we'll see why that is but is this
seen in a nice way in terms of like
almost like a textbook yeah where you
are able to show a little bit of text
you're able to put in MATLAB code you
will also be able to see the output I'll
show you another example of that
nice it's called as a live script okay
so let me run this for you so I will run
all I'm hoping it runs without or
showing any errors it's performing the
running here it's doing the network
loading and then it's performing the
classification and it's already
classified it so if you notice all of
the
puts so let me say I remove this yeah
let me run it all of my output plot
everything comes in the same window and
it's almost like a very nice notebook
yeah it's like one notebook where I have
the network properties I say what the
image thing is and then what the image
looks like and then I resize it and then
tell me what the variable name is and
then I can also export it to a PDF or a
HTML or a latex file so you save a lot
of time in rewriting or copy pasting
into save word or later or something
like that because it's already in the
form of a nice rich text editor yeah and
this is something that was introduced in
our 2016 it okay this is extension is
dot ml x okay any questions on this or
what are the live script go to that legs
how can you go to that live script let
me just show you an example so you can
you can hear in 17 B it says new script
or new live script you can click on that
and then I will I will have I will say
it's a text I want to put a heading I
will say and I triple is PR training
okay and then I'll put some I'll put
some heading same example one and then
I'll say plot sine wave then I will say
it is not text but now it will go into
code I will click on code okay and I
will say T equals minus PI pi
and I'll say plot sign off okay and now
when I run this particular section
I got yes is that nice yeah and what I
can do is I can go here and say X label
equals I can put it in here and as soon
as I run that section it will end up
getting updated right away
okay and I can also say perform
annotations or move it around or zoom it
and it will get reflected here as well
okay next what I can do is I will say I
want a text and I want it to be an
example so I'll say example - okay and
I'll say I want to perform take an AA
metric samples I can say that and then
I'll go to code I'll say Sims of X and
I'll say y equals sign of maybe let's
say X X square plus log of X and then
I'll say what is bit of wine that is
differential and I'll say what is in
tough white and I'll say F plot of what
I'll put it in a thing saying plot F of
Y and okay so far is it easy then let me
run this particular section and if you
notice it's of course it will take a
little bit of time so I got my value
which is say sine X square plus log X
and the differential is this correct - x
cos x square plus this one and then the
integral yeah and it's still evaluating
what the or how it should be plotting
because this is a more complex
expression because it's a friend
function so you will end up getting a
plot in some time or it might end up
showing an error but is this a nice way
for the students to learn and you know
you're able to see everything in line
itself right so this is what is known as
the live editor which is what I wanted
to show you in terms of deep learning in
terms of five lines of code
yeah and if you notice here how does
this plot look like is it very nice so
this blue one essentially shows my input
right this one here is my derivative the
sorry the yellow one is my derivative
and the orange one is my integral I can
put in legend if I want and I can say
um you know I can see why put in this
offline and then I can put in and I just
run or IRA I just run that any questions
we'll we'll wait for that to do it but
we'll go back to another example what I
would like to show you next is how do
you do it for multiple images okay so
let's let's take a look at that so I'm
gonna take a look at an example which
you will see in just a little bit okay
it's D it's not opening for me because
okay we just add two paths that's still
it's still taking a little while but you
know what I want what I wanted to show
you okay it did that
so you see here I'm able to get the
different things here yeah the
differential and the integral component
yeah now what I'm gonna do is I'm going
to take into account what happens when
there's a pre-trained Network I'm gonna
explore expose it a little more okay so
this may not work now because I see an
error but what I want to show you is the
overall workflow okay so I'm clear thing
and what is the first step I'm doing
here can someone tell me net equals Alex
net what does it do load the network and
then next component I'm inspecting the
network I will see what the network
layers are okay and then I'll also see
what the last part is what is there in
terms of classes okay I have a thousand
by one cell array so it essentially has
thousand different classification okay
that is my output layer then what am I
going to perform I'm not going to take
what just one image what do I have here
like one particular folder so here if
you go here in MATLAB I have a folder
with a lot of images around twelve
images over here okay and I don't want
to keep up doing a lot doing it over and
over again or put write a different for
loop and all that there's a smarter way
of doing it okay so what I will do is I
will essentially end up taking this
image what is the path of the image
okay and I will show what the image is
yeah but I won't do this just once what
I will do is I will run this in a loop
using what is known as beep restore it's
like a pointer okay it will essentially
take into account all the files that are
there in this particular folder okay and
this will be the pointer and whatever I
get here whatever I say image data
stores that as image path this it will
essentially store it like a pointer it
won't load all the data into the
workspace but it will end up saying I
have IDs I have three images plus nine
more so a total of twelve images but I'm
I'm only having it as a pointer is that
okay yeah and I'm displaying that next
what I will do is while I'm doing that
while I ensure that I end up getting all
the images I'm performing the same thing
I read the image sorry I read the data
okay and I resize it and then I classify
the image okay but I'm running it over
thousand samples yeah and you know what
is the max score that I get and show me
what it is okay so is this a seashore
here yeah but what about this this is a
breakwater this is okay but then is this
a hot dog No so you're getting a value
that's point 1 1 so it means to be
trained better is this a bakery it's a
part of a bakery but it should have been
cupcakes is that right this is a sheep
no it's not is this a lakeside maybe but
a frozen lake site but it took the
sunset into account and then is this a
bucket no of course there's a kid inside
a bucket it forgot the kid but it showed
did the bucket this is a couch of course
it is then is this a cardigan perhaps
not and then is this a Japanese spaniels
so tidal no this is a fire extinguisher
sand bar no its beach sand yeah and you
can puff up the same thing by you know
reading something from let me not try to
run this section you can read any image
and then you're able to classify it and
you can do that for F web image as well
is it very easy like what is the only
key thing that we changed here we ended
up we ended up storing the whole data
path in what is known as IDs we provided
it with a pointer and we were able to
show what the overall thing is for all
the images in that folder is that
correct yeah so an extension of what you
did in this case ok so let's go back to
the slides
so pre-trained networks have a
predetermined layer order which makes
them effective for classifying images
they're typically trained to classify a
lot of images different networks so say
Google net will be different they are a
great starting point but not
consistently accurate ok we will discuss
what transfer learning is tomorrow if
there's a way you can add more layers to
it and things like that yeah so what I
want to say is deep learning is
definitely not complicated it can be
very easy ok if you notice it's simple
the only thing is you need to understand
the concept of neural networks pretty
well I would actually want to take a
little bit of time and explaining the
background of a convolutional neural
network which is there so if you notice
I have an input what is this layer here
feature learning and then the
classification I want to spend a little
time on feature layer so assume that you
want to detect numerals okay so the
convolutional neural network has three
components what's the first layer your
convolution layer the second layer is
the max pooling layer third layer is
called the ALU layer okay I'll tell you
what each of
leaders are and slob for questions and
we can continue tomorrow so the
convolution layer what it does is it
takes the input and searches for
multiple patterns okay in this case it's
a three by three matrix how many
patterns can we have we can have 27
patterns is that correct this pattern
here is there in this yeah this straight
pattern can be there in this here or
this one is there here so what it does
is it takes each of these patterns and
slides it through the image and performs
correlation okay and sees which patterns
give the most score so it performs
correlation and tries to see what the
patterns that give the most score are
and chooses that particular pattern okay
so any questions so far
okay these are of course binary images
the next part is all the patterns are
compared to the patterns on a new image
okay it starts at a left corner slide
over one by one pixel and repeat for the
next pattern it's a greedy search
algorithm next a good pattern matching
what would happen is so this one will
only end up doing good against this
pattern it won't do well against the
other pattern so we'll see what the best
pattern is okay so what we try what we
are going to get here is in this case
will we end up getting a score for all
of these patterns is that right yeah but
it will occur in various parts of the
image
you may end up getting a matrix like
this you understand you will end up
getting a matrix like this which takes
what the score is and you say in this
case this was a pattern that was the
best so let me have for this pattern was
the best let me have eight in this case
again five and then six this is like
down sampling we shrink the large images
while performing them but preserving the
important information that is a second
layer which is called the max pooling
the third thing the rectified linear
units layer is if you have a negative
value in your image they are all set to
zero mean they're all set to zero and
which is where we have the three
components so I just want to go back to
the same thing so what do we have here
the convolution layer
forms pattern search over multiple
different types of patterns and you have
the rail U which is essentially sets the
con sets of a correlation value to zero
what this pooling do it will essentially
perform down sampling yeah and that is
repeated over multiple things and then
once you get that value it is flattened
out okay and then there's one thing
called the fully connected thing and
then we perform the softmax each of
these details will be sent to you
shortly and these are mathematical
operations we essentially try to instead
of a vector we try to ensure that it's a
flattened layer and then we ensure that
this connection between the image pixels
and then you end up saying what is the
best correlation that's over there is
that clear yeah so this is what you
might have seen in your MATLAB command
window here so in the first case what
was the first layer what was the first
layer here
imagine put the second layer convolution
value max pooling again convolution
value max pooling convolution value
convolution value multiple times and
then finally what is the last layer
classification output yeah so is that in
sync with what you saw as um not here
sorry what you saw as the different
layers so okay so this is where your
neural network background will come off
help in deep learning it's more the
number of hidden layers better the
classification and which is why deep
learning has become a bigger phenomena
and why has that become because earlier
you were neural networks were very
computationally intensive but at this
point of time they are not and we are
able to you know use GPUs in order to do
that ok so what I would like to touch
upon 30 minutes tomorrow is what are the
best cases where you can do um this form
of an approach or in a few cases where
you might need to introduce additional
layers and perform the lay learning ok
so those are the things that we will be
talking about so just to summarize what
I want to show you
is of course you have the flattened
layer which flattens in neurons in a
previous layer and then fully connected
which it says which are the high level
layers and softmax it's on the scores
and the probabilities what I want to
take tomorrow is when do you end up or
sorry when you end up doing two
different approaches we will talk about
it tomorrow but for today the workflow
is you perform the pre-processing define
the layers in CNN said the training
options train the networks and test and
deploy the Train networks same as a
neural network workflow access images
define the hidden layer define the
weights define of a few other things
train the network and then by validated
and then classify it is that correct and
then repeat these orange steps till it
reaches a desired level of accuracy is
that clear clear okay so I'm gonna be
stopping today at this point if that's
okay
and I'm happy to take a few questions I
know I was told that I have time until
4:00 so I wanted to spend around five
minutes
on questions and then what I would like
you to do as a homework and come
tomorrow if possible yes yeah okay while
I'm checking what I should give you as a
homework if you cannot ask me any
questions that would be very helpful
well yeah while you think of questions
what I wanted to talk to you about is
please Google what is known as deep
learning MATLAB on RAM it's a free
two-hour training online training anyone
can access okay what it will end up
showing you is what the convolutional
neural networks are how do you
pre-process image how do you use pre
trained networks you don't need matlab
installed on your computer you can
essentially end up like you know are
doing it in your own computer with where
there's no MATLAB installed and you can
say you know launch the course and I'll
just show you what the course looks like
again so let me um let me try to log in
to mine it's called the deep learning
on-ramp and MATLAB okay when you finish
this course of course you get a
certificate
I'm all
happy to issue certificates from math
works for people who attended this if
needed in addition to this what what I
can do is I can say click on you know
I'll just essentially take the first
example first example that's there here
it shows a green bar because I've
completed it it it runs a little bit of
video that's there and then I can say
next and then again the course overview
it gives me and next now it shows me an
example on how to identify a few objects
in some images so as it is by clearing
those who have completed 5% of the
course now it says you will be
performing this this is the same example
that you performed ok now what you can
do is it will say use the I am read
function to or you know read the file
name so all I need to go and do over
here is I equals I am read and I can say
you know I can I can use some what I
what do I have as a file name I will
save file
oh one dot jpg and what do I need to
store it into I need to store it in a
variable called I image one yeah and I
can say submit and once I've submitted
it it's gonna run it and it says it is
correct
ok next it will take me to the next task
what was my next task I need to view the
image yeah so all I need to do is I am
show off I am G 1 and I'll submit it
we'll run it again and it's saw it and
it is correct ok
then I go to the next task so will you
be able to do things section 1 and 2
before tomorrow it's very easy but it
would be great if you can do section 1
and 2 in the deep learning on-ramp
before tomorrow it would be very nice
and I'd like to show you how this
certificate will look like um let's see
if I'm able to
so I can say download the progress
report I actually will end up getting a
nice PDF which says you know I have
completed at 5% I've done introduction
100% but I'm not completed the others
it's good for you to show that you get
us a certificate like this okay so I'm
also happy to give you a certificate for
indicating the fact that you attended
our today's session and or tomorrow
session but this is something that's
generated automatically for you molls so
will you be able to do the two tasks two
chapters that is introduction and using
pre train networks before tomorrow yes
it would be helpful so go to matlab
on-ramp which just say google matlab
deep learning learning on-ramp you just
need to create a math works account and
you can click on that and it will help
you launch it's a free course okay okay
so I took more time than that I promise
I said I would give you some time for
questions any questions at this point of
time or anything that you would like me
to cover tomorrow
[Music]