{"id":31944405,"url":"https://github.com/ehsanik/vision-hw5","last_synced_at":"2025-10-14T10:24:18.982Z","repository":{"id":54095778,"uuid":"133125951","full_name":"ehsanik/vision-hw5","owner":"ehsanik","description":"Use PyTorch to train a classifier on Cifar-10","archived":false,"fork":false,"pushed_at":"2018-05-17T22:11:43.000Z","size":20,"stargazers_count":13,"open_issues_count":0,"forks_count":24,"subscribers_count":0,"default_branch":"master","last_synced_at":"2024-04-24T00:23:41.565Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ehsanik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-12T07:58:01.000Z","updated_at":"2024-03-31T17:38:03.000Z","dependencies_parsed_at":"2022-08-13T06:40:53.572Z","dependency_job_id":null,"html_url":"https://github.com/ehsanik/vision-hw5","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ehsanik/vision-hw5","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehsanik%2Fvision-hw5","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehsanik%2Fvision-hw5/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehsanik%2Fvision-hw5/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehsanik%2Fvision-hw5/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ehsanik","download_url":"https://codeload.github.com/ehsanik/vision-hw5/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehsanik%2Fvision-hw5/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279018782,"owners_count":26086452,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-14T10:24:14.447Z","updated_at":"2025-10-14T10:24:18.976Z","avatar_url":"https://github.com/ehsanik.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CSE 455 Homework 5 #\n\nWelcome friends,\n\nIt's time for neural networks! But this time with PyTorch! Yey! This homework might need a longer running time. Keep this in mind and start early.\n\nPyTorch is a deep learning framework for fast, flexible experimentation. We are going to use it to train our classifiers.\n\nFor this homework you need to turn in `models.py`, `dataloder.py` and a PDF file `Report.pdf` including your plots and reasonings.\n\n## 1. Installing PyTorch ##\n\nYou can either use [official PyTorch tutorial](https://pytorch.org/), [Our tutorial(Still getting updated)](https://github.com/ehsanik/pytorch_installation) \nor come to the workshop on Friday 11th, at 12pm in NAN181.\nYou can find a tutorial for MNIST [here](https://pytorch.org/tutorials/beginner/blitz/neural_networks_tutorial.html#sphx-glr-beginner-blitz-neural-networks-tutorial-py), a sample network for MNIST [here](https://github.com/pytorch/examples/blob/master/mnist/main.py), and the PyTorch slides are posted on the website.\n\n## 2. Find the best network ##\n\nIn this part, we want to find a network architecture that can obtain reasonable results on Cifar-10 dataset. \nFor the first steps you don't need to worry about reading data or calculating the accuracy. \nYou are just going to implement the model structure and the forward pass.\nUse `plot_progress.py` to compare methods and checkout how train and test accuracy changes. \nIn the beginning and the end of each run of the program the address of the log\nfile for which the accuracies and losses are recorded is printed (It will look something like `logs/2018-05-09_14:39:36_log.txt`). You can use the following\ncommand to plot the progress. \n\n```bash\npython plot_progress.py --file_name \u003cLOG FILE ADDRESS\u003e\n```\n\nNote that you don't need to wait until the training is done to plot the progress.\nReport the final plot for every model in your `Report.pdf` file. \nCompare how fast the models converge and how is the test accuracy changing during training.\n\n\n## 2.1. Training a classifier using only one fully connected Layer ##\n\nImplement a model to classify the images from Cifar-10 into ten categories using just one fully connected layer (Remember that fully connected layers are called Linear in PyTorch).\nIf you are new to PyTorch you may want to check out the tutorial on MNIST [here](https://pytorch.org/tutorials/beginner/blitz/neural_networks_tutorial.html#sphx-glr-beginner-blitz-neural-networks-tutorial-py).\nFill in the code for LazyNet in `models.py`. Run the model for 50 epoch and report the plots and accuracies: \n\n```bash\npython main.py --model LazyNet --epochs 50\n```\n\nAnalyze the behavior of your model (how well does it work?, how fast does it train?, why do you think it's working/not working?) \nand report the plots in your report file.\n\n## 2.2. Training a classifier using multiple fully connected Layers ##\n\nImplement a model for the same classification task using multiple fully connected layers. Start with a fully connected layer that maps the data from image size (32 * 32 * 3) to a vector of size 120, followed by another fully connected that reduces the size to 84 and finally a layer that maps the vector of size 84 to 10 classes.\nFill in the code for BoringNet in `models.py`. Run the model for 50 epoch and report the plots and accuracies \n\n```bash\npython main.py --model BoringNet --epochs 50\n```\n\nAnalyze the behavior of your model and report the plots in your report file.\n\n### 2.2.1. Question ###\n\nTry training this model with and without activations. How does the activations (such as ReLU) affect the training process and why?\n\n## 2.3. Training a classifier using convolutions ##\n\nImplement a model using convolutional, pooling and fully connected layers. Fill in the code for CoolNet in `models.py`. \nRun the model for 50 epoch and report the plots and accuracies \n\n```bash\npython main.py --model CoolNet --epochs 50\n```\n\nExplain why you have chosen these layers and how they affected the performance. \nAnalyze the behavior of your model and report the plots in your report file.\n\n### 2.3.1. Question ###\n\nTry using three different values for batch size. How do these values affect training and why?\n\nFor running the model using a custom batch size you can use:\n\n```bash\npython main.py --model CoolNet --epoch 50 --batchSize \u003cYour Batch Size\u003e\n```\n\n## 3. How does learning rate work? ##\n\nWhen you are trying to train a neural network it is really hard to choose a proper learning rate. \nTry to train your model with different learning rates and plot the training accuracy, test accuracy and loss and compare the training progress \nfor learning rates = 10, 0.1, 0.01, 0.0001.\nUse command:\n\n```bash\npython main.py --lr \u003cLearning Rate\u003e --model CoolNet --epoch 50\n```\n\nAnalyze the results and choose the best one. Why did you choose this value?\n\nDuring training it is often useful to reduce learning rate as the training progresses (why?). \nFill in `adjust_learning_rate` in `BaseModel` in `models.py` to reduce the learning rate by 10% every 50 epoch and observe the behavior of network for 150 epochs. \nTurn in your plots in `Report.pdf`.\n\n```bash\npython main.py --model CoolNet --epoch 150\n```\n\n## 4. Data Augmentation ##\n\nMost of the popular computer vision datasets have tens of thousands of images. \nCifar-10 is a dataset of 60000 32x32 colour images in 10 classes, which can be relatively small in compare to ImageNet which has 1M images. \nThe more the number of parameters is, the more likely our model is to overfit to the small dataset. \nAs you might have already faced this issue while training the CoolNet, after some iterations the training accuracy reaches its maximum (saturates)\nwhile the test accuracy is still relatively low. \nTo solve this problem, we use the data augmentation to help the network avoid overfitting.\n\nAdd data transformations in `dataloder.py` and compare the results. \nJust be aware that data augmentation should just happen during training phase. \nRun the following command with and without data augmentation and compare the result.\n\n```bash\npython3 main.py --epochs 200 --model CoolNet --lr 0.01\n```\n\n## 5. Change the loss function ##\n\nTry Mean Squared Error loss instead of Cross Entropy and see how this affects the results and explain why you think this is happening. \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehsanik%2Fvision-hw5","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fehsanik%2Fvision-hw5","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehsanik%2Fvision-hw5/lists"}