Skip to content

s-mostafa-a/pytorch_learning

Repository files navigation

Playing with PyTorch

This repository is my playground for getting to know PyTorch library of python. Mainly I've gone through PyTorch's 60 minutes blitz and Aakash NS's webinar. To install all of your requirements, just run the command below in your terminal:
pip install -r requirements.txt

Code Components Description

This is a small and useful unittest for the tensors generated by models. It has two responsibilities:

  • check the shape of a tensor
  • check if two tensors are equal in values

The first one will be quite useful if you are creating a novel structure of neural networks. Shape checking for tensor will provide a pretty decent prevention to future unwanted results or bugs.

This directory has got all details I've extracted from tutorials. Especially in the notes.py file, I've written some comments which I think they can be helpful for all my future projects.

This one has got two files, which I've implemented linear regression with two approaches: with and without nn class of torch.
Both are quite simple codes, but it was necessary for me to know what is going on inside the nn.Linear class. Also, the Dataset is a random matrix in which columns are some random features.

At this directory, I've written two classifications for the MNIST dataset. They do the same thing logically, but they are different in implementation. The one with _not_best_practice ending is all written by myself, and the other one is from Aakash's webinar with some modifications.

Things implemented here are just like the above's, but instead of a linear model, I've put a DNN model with just one hidden layer, which is so simple.

Here is also something like the simple deep neural network, two ways of implementation, which are logically the same. The difference between them with simple deep neural nets are just in the models.

This one is quite different from the above models. Two main files are MNSIT_GANs and CIFAR10_GANs, which the first one is inspired by Aakash's webinar (all parameters and models are the same as the webinar's parameters). Inside the model, the generator tries to generate handwritten digits like the MNIST data set. You can see the model's progress at each epoch in the following gif:
Alt Text
But at the second one, I've tried (and am trying) to generate pictures like the cifar10 dataset. First, I converted the pictures to grayscale for convenience, then I tried some different parameters and functions, but there were not any significant results. For the future work, I will continue exploring the best architecture and parameters for the model. If you think you have got any better solutions, please make a pull request.