Skip to content

This repo contains all the code for the PyTorch demo conducted as part of CS F429: Natural Language Processing.

Notifications You must be signed in to change notification settings

greenfish8090/PyTorch-Demo-NLP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyTorch demo

This repo contains all the code for the PyTorch demo conducted as part of CS F429: Natural Language Processing.

Code organization

pytorch_model.ipynb

Contains the code for a very basic pytorch module. Meant to be a tutorial on how to build a neural network

training_mnist.ipynb

Contains a full minimal training pipeline:

  • dataset and dataloader initialization
  • model creation
  • training
  • evaluation

Note that this is meant to be demo of PyTorch, so practices like validation aren't used. You should use them in all your projects.

Why MNIST and not an NLP dataset?

NLP is a sequence processing problem, and sequence models like transformers and RNNs are more involved than regular feed forward networks. I wanted to use a simple model that trains and produces results fast.

Why not CNN?

Wanted to keep things simple. Moreover if I did use a CNN this might as well be a computer vision course demo :)

rnn.ipynb

Contains code and illustrations that shed light into the inner workings of RNNs. Also shows how to implement manually in pytorch without using torch.nn.RNN
Finally, it shows how to use the torch.nn.LSTM module
After going through this, you should be able to train your own LSTM on whatever dataset you want.

transformer.ipynb

Jk, out of scope for now. Coming soon maybe?

Setting up

Colab link available here. Make a copy to your drive and play around.
If you want to run this code locally, follow these steps:

  1. Install anaconda/miniconda and set it up
  2. Clone this repository to your local
  3. In your anaconda/miniconda command prompt, run the following from the directory containing the cloned code:
    $conda env create --name <preferred_env_name> --file=environment.yml
    
  4. Run:
    $conda activate <preferred_env_name>
    $jupyter notebook
    
  5. A notebook should open on your browser and you'll be able to run everything.

You can use the same environment for your NLP course project as well.

Contact

If you have any doubts/suggestions please email me f20190040@hyderabad.bits-pilani.ac.in

Thanks for visiting!

About

This repo contains all the code for the PyTorch demo conducted as part of CS F429: Natural Language Processing.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published