pdfcoffee

soumyasankar99
from soumyasankar99 More from this publisher
09.05.2023 Views

Chapter 1Figure 29: Test accuracy for increasing the values of internal hidden neuronsIncreasing the size of batch computationGradient descent tries to minimize the cost function on all the examples provided inthe training sets and, at the same time, for all the features provided in input. SGD is amuch less expensive variant that considers only BATCH_SIZE examples. So, let us seehow it behaves when we change this parameter. As you can see, the best accuracyvalue is reached for a BATCH_SIZE=64 in our four experiments (see Figure 30):Figure 30: Test accuracy for different batch values[ 35 ]

Neural Network Foundations with TensorFlow 2.0Summarizing experiments run for recognizinghandwritten chartsSo, let's summarize: with five different variants, we were able to improve ourperformance from 90.71% to 97.82%. First, we defined a simple layer networkin TensorFlow 2.0. Then, we improved the performance by adding some hiddenlayers. After that, we improved the performance on the test set by adding a fewrandom dropouts in our network, and then by experimenting with different typesof optimizers:model/accuracy training validation testsimple 89.96% 90.70% 90.71%2 hidden(128) 90.81% 91.40% 91.18%dropout(30%) 91.70% 94.42% 94.15% (200 epochs)RMSProp 97.43% 97.62% 97.64% (10 epochs)Adam 98.94% 97.89% 97.82% (10 epochs)However, the next two experiments (not shown in the preceding table) were notproviding significant improvements. Increasing the number of internal neuronscreates more complex models and requires more expensive computations, butit provides only marginal gains. We have the same experience if we increasethe number of training epochs. A final experiment consisted of changing the BATCH_SIZE for our optimizer. This also provided marginal results.RegularizationIn this section, we will review a few best practices for improving the training phase.In particular, regularization and batch normalization will be discussed.Adopting regularization to avoid overfittingIntuitively, a good machine learning model should achieve a low error rate ontraining data. Mathematically this is equivalent to minimizing the loss functionon the training data given the model:min: {loss(Training Data | Model)}[ 36 ]

Neural Network Foundations with TensorFlow 2.0

Summarizing experiments run for recognizing

handwritten charts

So, let's summarize: with five different variants, we were able to improve our

performance from 90.71% to 97.82%. First, we defined a simple layer network

in TensorFlow 2.0. Then, we improved the performance by adding some hidden

layers. After that, we improved the performance on the test set by adding a few

random dropouts in our network, and then by experimenting with different types

of optimizers:

model/accuracy training validation test

simple 89.96% 90.70% 90.71%

2 hidden(128) 90.81% 91.40% 91.18%

dropout(30%) 91.70% 94.42% 94.15% (200 epochs)

RMSProp 97.43% 97.62% 97.64% (10 epochs)

Adam 98.94% 97.89% 97.82% (10 epochs)

However, the next two experiments (not shown in the preceding table) were not

providing significant improvements. Increasing the number of internal neurons

creates more complex models and requires more expensive computations, but

it provides only marginal gains. We have the same experience if we increase

the number of training epochs. A final experiment consisted of changing the BATCH_

SIZE for our optimizer. This also provided marginal results.

Regularization

In this section, we will review a few best practices for improving the training phase.

In particular, regularization and batch normalization will be discussed.

Adopting regularization to avoid overfitting

Intuitively, a good machine learning model should achieve a low error rate on

training data. Mathematically this is equivalent to minimizing the loss function

on the training data given the model:

min: {loss(Training Data | Model)}

[ 36 ]

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

Saved successfully!

Ooh no, something went wrong!