So we're now ready to train our CNN to CNN that we just constructed a pill, let's begin treating it.
So an increase it's actually quite simple to train CNN's well, neural networks compared to PyTorch.
That's a given by batting with PyTorch, to be honest.
It allows you some nitty-gritty control.
Some good python type style language that we can actually interact with.
Get the opposite inputs.
Perform operations in real time and loop.
It's quite nice.
However, wood carries a lot of that is abstracted away, and you can see what I mean here.
Once we have a model that's compiled here, all we have to do is no specified about a specified number
of epochs and we just do model dot fit.
We have history equals a model that fit only because the model not fit after every iteration of every
epoch.
I should say it outputs its towards tick accuracy to validation, lost validation, accuracy and training
loss us so we can plot this afterward.
So it's a good thing.
So don't don't worry about that.
So in the model that fit function, we simply input our training data or treating labels, specify what
that size, which is 128 we're going to use specify epochs verbose, which is a mode where we display
this information.
If you said that to zero, you get less information.
Instead of two, you get even more information during the training process.
I think it's just three modes right now.
Zero one two.
And then we specify our validation data in this tuple here.
This is the testino, and this is a test levels.
And then in the end, we can actually simply just do Model three, evaluate give it to tested the test
labels.
So the verbose to zero by, I think it's by default zero anyway, and we can get the score out of it.
The score gives you in scoring first index gives us a test loss.
Second index gives us the test accuracy.
So this is quite simple.
So now let's begin training this model.
Oops model wasn't defined, and that was because we didn't run this block of code previously.
And that's also because we didn't run the code above it.
Sorry about that, but it's a good practice to keep running these blocks of good.
Make sure you ran sequentially because they depend on each other.
And now we do need to run that.
Now we can start training our model, and there we go.
So it's beginning to first book.
Pretty soon you'll start seeing the output in real time as it goes through each batch.
There we go.
So what are some of his here?
This number is a number of batches in our data.
Remember, we set it at 128 well, 5th 60000, divided by 128 is 469.
So that's why you have four hundred and sixty nine as total number of batches here.
So you can see how quickly it's going through all the batteries in the data, taking the three seconds
of each one, which is actually much faster than our PyTorch model.
And I will see the PyTorch model in that.
In that proof, his example was slower, even though we're using the same hardware and GBU just because
of how we were doing things in the loop.
There's other ways with Pi too we can make things much faster.
But for now, that was just a basic example.
So I didn't want to complicate things too much for you guys.
One thing you wouldn't notice still is that after 10 epochs, the Python model was actually more accurate.
We're at 92 percent here with Keros, but if I, it was at ninety seven point eight percent accuracy,
and that probably has to do with the normalization that we with zero scented invito, which you can
see how it actually does make a difference where the convergence and at the end of the twenty five epochs
would still finished and quite in a very short space of time, we get ninety five percent accuracy in
the end.
And you can see the output, the Tesla says accuracy that came from the score, this variable and that
came from a model that evaluates here.
So we'll stop there for now.
And in the next section, we'll take a look at plotting our loss and accuracy charts.
See you in the next section.
Thank you.