what's going on everybody welcome to
part 6 of our antics with neural
networks tutorial series in this video
what were we doing is I'm just gonna run
through basically the the opposite of
what we've been doing so far aware we're
generating a classification based on a
number input to now what we're going to
do is we're going to have the actual
classification being the input and the
number is going to be generated so
basically what we want to be able to do
is input a 5 and have the neural network
draw us a 5 so I'm gonna go over the
code that I used to do just that really
this is all code that should look very
familiar to you guys just a few slight
changes so I don't really see any
benefit in us writing it out so for the
input basically we're just doing 15 rows
of encased in colons 20 versions of
whatever the number is that we want for
the label and I'll show that to you in a
minute so that's basically gonna look
like this so the so that the training
data is like this so it says hey draw me
an 8 boom here's an 8 and then it's
here's the input please draw me a - draw
me another - a 9 and so on and our goal
is to when when the user enters a 9 use
this as the primer and then do your
generation and the hope is that based on
this this primer it generates this now
the reason why I changed the classifier
or the the classification generator code
is because actually as I was doing this
tutorial and doing the write up I was
think I was working with the one hot
array and then I flipped it around and
said okay can we draw a number based on
the one hot array because the
classification didn't really work and
then I thought well it's probably really
challenging when you have like a one hot
array because eventually you know first
of all if you get that one hot array you
only have like one opportunity to get
that number right especially in the
classification you only have one
opportunity to get it right whereas you
have many opportunities if you give it
something like this like many many rows
basically of data and I think the same
is true when you're drawing something
where
if you just have the one one hot array
or vector or whatever you want to call
it as you begin to like slide your
window down because of the way that
we've done this too you can almost think
of it as like like think of it as like
this window here and as you slide it
down your window now for the generative
model is like this so at this point like
what if what if at this point it just
had one vector here right it would have
to get that one vector right and that
one number that one like in that vector
there's only one tiny difference between
the different classifications and in my
opinion that was probably making it
really challenging I think to learn so
anyways that's when I started doing this
and then as you saw in the beginning I
already knew that this would be
successful as I was filling this
obviously I didn't know that was gonna
be successful at the time when I built
this but as we've seen also with the
classification generator that Ellis also
seems to work or at least help now this
models been trained for about 90,000
steps so at least I want to let that
other one the classifier train for the
same amount anyway that's the input data
this is the code to make it again you
can go to the text-based version of this
tutorial to get it then we have the
sample number drawer this one's even
more challenging for us to determine you
know some sort of accuracy percentage
because really you would need an amnesty
law so fire to classify the output which
you could totally do I just didn't
really feel like doing it I was just
gonna eyeball it
so anyways this is the code that I've
written to actually just generate the
numbers so you just take the input it's
just straight up an input the primers
empty right now for you know nothing
that matters in the range of 15 we
generate this same as we basically did
it right here and then I'm actually
going to just clear this like that and
then wow true we just start iterating
through here now in this case basically
what we're trying to do this is using a
regular expression to attempt to find
the drawn number so it's just looking
for instances where you have two
brackets so bracket number one
bracket number two and then this is
actually a regular expression so so take
note I'm sorry this is the regular
expression that we're hunting for so
take note of the backslash bracket
versus no backslash bracket brackets a
you know part of a regular expression
syntax now so that's what we're doing
we're looking for two brackets followed
by literally anything in between those
two brackets so again in this case these
are encased by colons but then the whole
number is encased by two brackets and
another two brackets so our regular
expression is hunting for that once it
finds that if it doesn't find that it's
gonna actually just continue this loop
it's going to attempt to make another
prediction but once it does find that
it's going to go ahead and break it's
gonna print it out to the screen for us
and then we're going to convert it
because obviously this can't be drawn in
matplotlib so just like we had to
convert it to a very simplified and
condensed array this way we actually
have to convert it back out to something
that we can actually graph so that's
what we're doing here and then we go
ahead and just run an eval on it who's
Gary eval and then in show and then we
show it so that's that code there and
then I've actually already got it
running here it looks like I've hit some
keys let's just see if it to works so
because sometimes there is no number the
regular expression doesn't find anything
with two brackets sometimes this takes a
really long time so one of the numbers I
found that's really slow is a nine a two
however appears to be very very quick so
nice
let's do I don't know a for at least the
first one was successful eventually
we're gonna find one that is a mistake
it does make mistakes it draws some
weird things sometimes that's just it's
a generative model that's what it's
gonna do the training window I guess I
should probably mention what we did wow
this floor is actually taking a while
basically I trained this this was a
sequence length of 800 and it was a 128
by 3 whoa huh I've never seen this error
before image data can't convert to float
huh I wonder I wonder what was there
I wish I output what that was
unless that was it above it nine no yeah
that was it
shoot I wonder what didn't convert it
looked like it was actually gonna draw
us the number what a bummer something
was wrong though maybe it didn't I don't
know I don't know what would have caused
that to be honest it looked like it was
about right I wish we could have had
more more of a window there anyway let's
see if it can draw so for this time
apparently a four is a really
challenging number maybe I should know
there goes maybe I should pause alright
so yeah so the four works awesome you
get the idea I could draw a billion
other numbers but I don't think I'm
going to
so from here there's a few things we
could do one is I could continue
training this model I could also go
further with em this data so for example
there's eeehm nest which is actually all
numbers and then all letters upper and
lower case so we could do something like
that we could also just take it a little
further I was kind of thinking of doing
something with imagery so the first
thing that came to my mind was like the
cats versus dogs so tell it draw me a
cat and then it just draws a cat I think
that's going to be ultimately probably
too challenging I'm gonna kind of play
around with pictures of cats and see if
I threshold them and decrease their size
significantly if we can come to some
sort of like a 28 by 28 it's probably
too small
after a threshold to really notice that
something is a cat or a dog but
something maybe a 50 by 50 which is you
know quite a bit larger but yeah so so
I'm still gonna try to figure out what I
want to do there as far as continuing on
with this because this appears to me to
be relatively solved where you can have
it draw you a unique number and all that
so anyways that's pretty interesting to
me like I said I think it's pretty cool
cuz it's like always a new and unique
number that it draws which is just
interesting to me so anyways I think
that's it for now
and
I'll probably the next video will
probably have to wait a little bit
because I'm going to let that other
model train and finish and see if we can
get the classification generator to work
as well so using a generative model to
do classification it's still kind of
interesting to me so anyways that's
going to be it for now if you've got
questions comments concerns whatever
feel free to leave them below otherwise
I will see you in another video