Advertisement
juanfkurucz

Untitled

Feb 16th, 2021
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. ################################################################################
  2. # TODO: #
  3. # Experiment with any architectures, optimizers, and hyperparameters. #
  4. # Achieve AT LEAST 70% accuracy on the *validation set* within 10 epochs. #
  5. # #
  6. # Note that you can use the check_accuracy function to evaluate on either #
  7. # the test set or the validation set, by passing either loader_test or #
  8. # loader_val as the second argument to check_accuracy. You should not touch #
  9. # the test set until you have finished your architecture and hyperparameter #
  10. # tuning, and only run the test set once at the end to report a final value. #
  11. ################################################################################
  12. model = None
  13. optimizer = None
  14. epochs = 10 #should be 10
  15.  
  16. # *****START OF YOUR CODE (DO NOT DELETE/MODIFY THIS LINE)*****
  17.  
  18. channel_0 = 3
  19. channel_1 = 36
  20. channel_2 = 66
  21. channel_3 = 126
  22. channel_4 = 254
  23. channel_5 = 254
  24. out_conv_size = channel_5 * 32 * 32
  25. classes = 10
  26. learning_rate = 5e-4
  27. hidden_layer_size = 200
  28.  
  29. model = nn.Sequential(
  30. nn.BatchNorm2d(channel_0),
  31. nn.Conv2d(channel_0,channel_1,kernel_size=3,padding=1),
  32. nn.PReLU(channel_1),
  33. nn.Dropout2d(p=0.05),
  34. nn.MaxPool2d(2),
  35.  
  36. nn.BatchNorm2d(channel_1),
  37. nn.Conv2d(channel_1,channel_2,kernel_size=3,padding=1),
  38. nn.PReLU(channel_2),
  39. nn.Dropout2d(p=0.05),
  40. nn.MaxPool2d(2),
  41.  
  42. nn.BatchNorm2d(channel_2),
  43. nn.Conv2d(channel_2,channel_3,kernel_size=3,padding=1),
  44. nn.PReLU(channel_3),
  45. nn.Dropout2d(p=0.05),
  46. nn.MaxPool2d(2),
  47.  
  48. nn.BatchNorm2d(channel_3),
  49. nn.Conv2d(channel_3,channel_4,kernel_size=3,padding=1),
  50. nn.PReLU(channel_4),
  51. nn.Dropout2d(p=0.05),
  52. nn.MaxPool2d(2),
  53.  
  54. nn.BatchNorm2d(channel_4),
  55. nn.Conv2d(channel_4,channel_5,kernel_size=3,padding=1),
  56. nn.PReLU(channel_5),
  57. nn.Dropout2d(p=0.05),
  58. nn.MaxPool2d(2),
  59.  
  60. Flatten(),
  61.  
  62. nn.BatchNorm1d(channel_5),
  63. nn.Linear(channel_5, hidden_layer_size),
  64. nn.PReLU(hidden_layer_size),
  65.  
  66. nn.BatchNorm1d(hidden_layer_size),
  67. nn.Linear(hidden_layer_size, classes),
  68. )
  69.  
  70. # you can use Nesterov momentum in optim.SGD
  71. #optimizer = optim.SGD(model.parameters(), lr=learning_rate, momentum=0.4, nesterov=True)
  72. optimizer = optim.Adam(model.parameters(), lr=learning_rate, weight_decay=0.05, amsgrad=True, betas=(0.5,0.75))
  73.  
  74. # *****END OF YOUR CODE (DO NOT DELETE/MODIFY THIS LINE)*****
  75. ################################################################################
  76. # END OF YOUR CODE
  77. ################################################################################
  78.  
  79. # You should get at least 70% accuracy
  80. train_part34(model, optimizer, epochs=epochs)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement