The wandb report link is: https://wandb.ai/adi00510/fashion_mnist/reports/-Assignment-1--Vmlldzo1MjA1ODY
-
Question 1
- Just by running the code (in google colab), we can see the output of the code in wandb.
- Link for the .ipynb file: https://colab.research.google.com/drive/1CpE6keY5Tq9tkk8Sygkd01azFXKzbYrn?usp=sharing
-
Question 2
- Here we created a class called Neural_network with parameters x_train,y_train,input_dimension,hidden_layers_size,hidden_layers,output_dim,batch_size,epochs,activation_func,learning_rate, decay_rate,beta,beta1,beta2,optimizer,weight_init
- Here when we create an object to this class then we need to pass the training data (x_train,y_train), input dimension size, hidden layer size, number of hidden layers, output dimension, batch size, number of epochs, which activation function we want to use, learning rate, decay rate, beta, beat1, beta2 for adam optimizer, which optimizer we want to use and which which weight initializer we want to use.
- In this python file we implemented gradient descent optimizer; activation functions of sigmoid, tanh and relu, we can use any one of this activation functions; and random and xavier weight initializers.
- Here we can use any batch size, any learning rate, any epochs while creating the object of this class.
- Link for the .ipynb file: https://colab.research.google.com/drive/1wNL2i7XOjhhkv43t9uUplBJFiqTalM6M?usp=sharing
-
Question 3
- Here we implement optimizers like sgd(stocastic gradient descent), momentum, Nestrov Accelerated Gradient, RMS Prop, ADAM and NADAM.
- If we want to use RMS Prop as an optimizer then while creating the object for this class we will send optimizer="rmsprop" then RMS Prop optimizer will be used for computing.
- Similarly
- If we want to use SGD optimizer then we use optimizer="sgd"
- If we want to use Momentum optimizer then we use optimizer="momentum"
- If we want to use NAG optimizer then we use optimizer="nestrov"
- If we want to use Adam optimizer then we use optimizer="adam"
- If we want to use NAdam optimizer then we use optimizer="nadam"
- Link for the .ipynb file: https://colab.research.google.com/drive/1x4xMaHQRW-tOxzyaa-p5BaMc2CV4oWNs?usp=sharing
-
Question 4
- First, we have splitted the train data in 9:1 ratio. 90% of the data is for training purpose and 10% of the data is for cross validation.
- Then, we have set the sweep function of wandb by setting up different parameters in sweep_config.
- By runnig the below code we can start seeing the ouput within our wandb project.
wandb.agent(sweep_id,train)
- Link for the .ipynb file: https://colab.research.google.com/drive/1NIEBtntraCGSMvUIWTFTA062pf1_JdJ5?usp=sharing
-
Question 7
- We have used test data for plotting the confusion matrix.
- We have used the model which was giving highest validation accuracy for plotting the confusion matrix.
- The model is as follows:
- optimizer : nadam
- activation : tanh
- batch size : 64
- hidden layers : 2
- learning rate : 0.002
- weight decay : 0.1
- By running the below code we can see plot the confusion matrix in our wandb project:
wandb.init(project='fashion_mnist',entity='adi00510',reinit=True) nn=Neural_network(x_train,y_train,784,64,2,10,64,7,'tanh',0.002,0.1,0.9,0.9,0.99,'nadam','xavier') nn.calculate_accuracy(x_test,y_test,True)
- Link for .ipynb file: https://colab.research.google.com/drive/1h391HHmOpxQdw3kSvSBxkv3-pZNEeRx7?usp=sharing
-
Question 8
- In this file we have implemented squared error loss as we are doing cross entropy loss in the previous questions.
- Now we compared this squared error loss with cross entropy loss by running it on 4 configurations.
- In most of the cases squared error loss will not perfom better as compared to cross entropy loss in terms of cross validation accuracy, but in some cases cross validation accuracy will be very close.
- Link for .ipynb file: https://colab.research.google.com/drive/1rX7S5-qy1EROXNz8EdGx3BAp-59dqcum?usp=sharing
-
Question 10
- In this file we loaded Mnist data from keras dataset and we used 3 best configruations by observing the previous configruations which we have used for fashion_mnist dataset.
- By running this configruations we got test accuracy as following 96.98%, 95.32%, 92.79% respectively for these 3 best configruations
- Link for .ipynb file: https://colab.research.google.com/drive/1NzfEEud_brIY2Q4fivccHrkEPRsTyuDc?usp=sharing