09.05.2023 Views

pdfcoffee

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Neural Network Foundations with TensorFlow 2.0

Okay, let's try the other optimizer, Adam(). Pretty simple:

# Compiling the model.

model.compile(optimizer='Adam',

loss='categorical_crossentropy',

metrics=['accuracy'])

As we can see, Adam() is slightly better. With Adam we achieve 98.94% accuracy on

training, 97.89% on validation, and 97.82% on test with 20 iterations:

Figure 22: Testing with the Adam optimizer

One more time, let's plot how accuracy increases on training and test sets when the

number of epochs increases (see Figure 23). You'll notice that by choosing Adam as

an optimizer, we are able to stop after just about 12 epochs or steps:

[ 30 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!