Project 4: Classification and Segmentation

Calvin Tang | calvintang@berkeley.edu | 3031974882

Part 1: Image Classification

As a note, I drew heavily from various tutorials I found online. I based much of my work on this tutorial for the creation, training, and testing of my neural network. I credit this tutorial for helping with the class accuracy.

Definition of Model

Below is a screenshot of my convolutional neural network. I was sure to include two layers within my network according to the specifications of the assignment.

Here, I instantiate my model. You can find the architecture of the model printed below.

Loading the Dataset

Following the creation of my neural network, I downloaded the Fashion MNIST dataset and loaded them into my notebook. I was able to receive both the training and testing sets, after which I used a random sampler to prepare my dataloaders. Below, you can see that I split my training set into a training loader and a validation loader, such that my network could improve itself upon iteration. I received help from fellow student Kenny Chen in this part of the project.

Training Results

I performed training on my model using the train_sampler and val_sampler created earlier. I used a total of 5 epochs. At the end of each epoch, I ran my model on the validation set to check its accuracy and fine tune the model. Below is the output of the training process, where the accuracy of training and validation were printed for each epoch.

Here are the plots of my training and validation accuracy throughout the training process of my model. The training accuracy fluctuates a lot, but continuously improves as the training continues. You can see the validation accuracy constantly improving as the number of epochs increased.

Testing Results

Below are the results of my testing! By running my model on the test set and tracking the correct labels, I achieved an accuracy of 89.36%! Given the loose requirements of the assingnment, I wasn't sure what threshold to aim for with accuracy. Nonetheless, I was pleased with my results. Here, we can see the class-by-class accuracy, as well as the lines of code I had to generate these results. We can see that many of the classes had very high accuracy when testing. Some of the classes had rather lower accuracy numbers, but often predicted the correct label. This could be due to the type of clothing of the class and the vagueness of the shapes of input image. I suppose my model did not perform as strongly on those for some reasons such as that.

Filter Visualizations

Below, I display the visualization my convolutional filter. Both convolutional layers in my architecture were the same, so the output images were the same for both layers.

Class Predictions

Here, we have some correct predictions and incorrect predictions from my model. As I mentioned earlier, some of the accuracy numbers for some categories for my model were quite high, so I was not able to find incorrect predictions for those classes. Perhaps that's a great thing!

Class 0: T-Shirt/Top

Class 1: Trouser

Class 2: Pullover

Class 3: Dress

Class 4: Coat

Class 5: Sandal

Class 6: Shirt

Class 7: Sneaker

Class 8: Bag

Class 9: Ankle Boot

I can see why my network made some incorrect predictions on the images that it did. Viewing them myself, I would even be confused by the shape of the item and what category it would fit into. Overall, the model is not perfect and I did not expect it to be. I still think it was very cool to be able to write out this network to be able to learn through training and produce a pleasing output.

Part 2: Semantic Segmentation

I played around a little bit with part 2, but was not able to get very far with moving around and the situation going on right now. Unfortunately, I don't have anything to show for this section.