Project 3
The first step in doing this project was importing the 10,000 images into pycharms. I split my images up into two groups: testing images (accraims) with 9,000 images and testing images (testing) with 1,000 images. After bringing the images in, I made sure to check the length of the images and labels to make sure they were lining up. Following this, I divided the training images and testing images by 255.0 to normalize the images. I began by creating a DNN model and then moved to the CNN model. For the DNN model, I included 1 flatten layer, and 3 dense layers (64, 64, and 1). Then I added in 3 convolutions (16, 32, and 64). Each of these convolutions had the activation= ‘relu’. When making the CNN, I tried many other variations (more convolutions and less convolutions with a different number of layers for each). I also tried a few other optimizers and loss function but it seems that RMSprop and binary crossentropy worked the best. The optimizer ‘Adam’ only did slightly worse than RMSprop. The CNN I used is shown below. The ‘activation = ‘relu’ (relu stands for rectified linear unit- linear function) function works by outputting a value only if the inputted value is greater than zero (positive). If the value is a negative number, the model will output ‘0’.
For the model.compile function I used RMSprop as my optimizer (with a learning rate of 0.001). The loss function I used was the mse, and the metrics were ‘mse’ and ‘mae’. The optimizer RMSprop works by providing an average of the square of gradients, and then divides the gradient by the square root of the average (from the first step). The MSE loss function is good for providing a mean squared error between the values we have and what we are trying to predict. I ran model.fit with all 9,000 images, so I had 90 steps_per_epoch and a batch_size of 100. I began by running 3 epochs and go an mae of 29.5612. However, after running with 6 epochs, I got an mae of 25.0337 and an mse of 964.7205.
The first epoch began with a loss of 2,358, and ended with a loss of 964.72 at epoch number 6. The mae began at 38.85 at epoch number one, and ended at 25.0337 at epoch number 6. Each epoch took about 15 minutes to run.
model.evaluate took about 28 seconds to run and had a loss of 1501 and an mae of 33.9754. I noticed that this mae is slightly higher than the results from model.fit.
This graph above shows the loss per epoch for the convolutional neural network. the graph clearly shows that the decreased per epoch and ended with the lowest loss (epoch 6).
The graph above shows the mean absolute error. As before, the graph shows that the mae decreases with each epoch (with epoch 6 having the lowest mae).