:fire: Machine Learning Notebooks
# 🐙 Machine Learning Notebooks

This repo contains machine learning notebooks for different tasks and applications. The notebooks are meant to be minimal, easily reusable, and extendable. You are free to use them for educational and research purposes.

This repo supports Codespaces! 
- Spin up a new instance by clicking on the green `"<> Code"` button followed by the `"Configure and create codespace"` option. Make sure to select the dev container config provided with this repo. This setups an environment with all the dependencies installed and ready to go.
- Once the codespace is fully running, you can install all the libraries you will need to run the notebooks under the `/notebooks` folder. Open up a terminal and simply run `conda create --name myenv --file spec-file.txt` to install all the Python libraries including PyTorch.
- Activate your environment `conda activate myenv`. *You might need to run `conda init zsh` or whatever shell you are using... and then close + reopen terminal.*
- Finally you can try out if everything is working by opening a notebook such as `/notebooks/bow.ipynb`.

---

## Getting Started

<table class="tg">
  <tr>
    <th class="tg-yw4l"><b>Name</b></th>
    <th class="tg-yw4l"><b>Description</b></th>
    <th class="tg-yw4l"><b>Notebook</b></th>
  </tr>
  
  <tr>
    <td class="tg-yw4l">Introduction to Computational Graphs</td>
    <td class="tg-yw4l">A basic tutorial to learn about computational graphs</td>
    <td class="tg-yw4l"><a href="https://colab.research.google.com/drive/1eG1AF36Wa0EaANandAhrsbC3j04487SH?usp=sharing">
  <img src="https://colab.research.google.com/assets/colab-badge.svg" width = '' >
</a></td>
  </tr>
  
  <tr>
    <td class="tg-yw4l">PyTorch Hello World!</td>
    <td class="tg-yw4l">Build a simple neural network and train it</td>
    <td class="tg-yw4l"><a href="https://colab.research.google.com/drive/1ac0K9_aa46c77XEeYtaMAfSOfmH1Bl9L?usp=sharing">
  <img src="https://colab.research.google.com/assets/colab-badge.svg" width = '' >
</a></td>
  </tr>
  
  <tr>
    <td class="tg-yw4l">A Gentle Introduction to PyTorch</td>
    <td class="tg-yw4l">A detailed explanation introducing PyTorch concepts</td>
    <td class="tg-yw4l"><a href="https://colab.research.google.com/drive/1K7Ks1ERaS-w4rzW_ukeBag8mYRZME1es?usp=sharing">
  <img src="https://colab.research.google.com/assets/colab-badge.svg" width = '' >
</a></td>
  </tr>
  
  <tr>
    <td class="tg-yw4l">Counterfactual Explanations</td>
    <td class="tg-yw4l">A basic tutorial to learn about counterfactual explanations for explainable AI</td>
    <td class="tg-yw4l"><a href="https://colab.research.google.com/drive/1mTSRjqki3VsH9MVPfNtJ5nJxcCHvL8B6?usp=sharing">
  <img src="https://colab.research.google.com/assets/colab-badge.svg" width = '' >
</a></td>
  </tr>

  <tr>
    <td class="tg-yw4l">Linear Regression from Scratch</td>
    <td class="tg-yw4l">An implementation of linear regression from scratch using stochastic gradient descent</td>
    <td class="tg-yw4l"><a href="https://colab.research.google.com/drive/1br0hM79ORTVNXUpVgkV5t4o4AigGxfwk?usp=sharing">
  <img src="https://colab.research.google.com/assets/colab-badge.svg" width = '' >
</a></td>
  </tr>
  
  <tr>
    <td class="tg-yw4l">Logistic Regression from Scratch</td>
    <td class="tg-yw4l">An implementation of logistic regression from scratch</td>
    <td class="tg-yw4l"><a href="https://colab.research.google.com/drive/1iBoJ0kngkOthy7SgVaVQA1aHEROt5mra?usp=sharing">
  <img src="https://colab.research.google.com/assets/colab-badge.svg" width = '' >
</a></td>
  </tr>
  
  <tr>
    <td class="tg-yw4l">Concise Logistic Regression</td>
    <td class="tg-yw4l">Concise implementation of logistic regression model for binary image classification.</td>
    <td class="tg-yw4l"><a href="https://colab.research.google.com/drive/14hnFJvHDq9w7FGb8P6pd6-I7F3djTRG9?usp=sharing">
  <img src="https://colab.research.google.com/assets/colab-badge.svg" width = '' >
</a></td>
  </tr>
  
  
  <tr>
    <td class="tg-yw4l">First Neural Network - Image Classifier</td>
    <td class="tg-yw4l">Build a minimal image classifier using MNIST</td>
    <td class="tg-yw4l"><a href="https://colab.research.google.com/drive/1i94k-n97Z5r1KWV9Vly9IiKnYxf3Tfvu?usp=sharing">
  <img src="https://colab.research.google.com/assets/colab-badge.svg" width = '' >
</a></td>
  </tr>
  
  <tr>
    <td class="tg-yw4l">Neural Network from Scratch</td>
    <td class="tg-yw4l">An implementation of simple neural network from scratch</td>
    <td class="tg-yw4l"><a href="https://colab.research.google.com/drive/1YBcEZMUHhJUiwOIwQbqwmAAGrRznpP_E?usp=sharing">
  <img src="https://colab.research.google.com/assets/colab-badge.svg" width = '' >
</a></td>
  </tr>
    <tr>
    <td class="tg-yw4l">Introduction to GNNs</td>
    <td class="tg-yw4l">Introduction to Graph Neural Networks. Applies basic GCN to Cora dataset for node classification.</td>
    <td class="tg-yw4l"><a href="https://colab.research.google.com/drive/1d0jLDwgNBtjBVQOFe8lO_1WrqTVeVZx9?usp=sharing">
  <img src="https://colab.research.google.com/assets/colab-badge.svg" width = '' >
</a></td>
  </tr>
 
  </table> 
  
  
## NLP  
<table class="tg">
  <tr>
    <th class="tg-yw4l"><b>Name</b></th>
    <th class="tg-yw4l"><b>Description</b></th>
    <th class="tg-yw4l"><b>Notebook</b></th>
  </tr>
  
  <tr>
    <td class="tg-yw4l">Bag of Words Text Classifier</td>
    <td class="tg-yw4l">Build a simple bag of words text classifier.</td>
    <td class="tg-yw4l"><a href="https://colab.research.google.com/drive/19suDts9MNIhx0TeGO26_BIY2Xc0n6DBC?usp=sharing">
  <img src="https://colab.research.google.com/assets/colab-badge.svg" width = '' >
</a></td>
  </tr>
  
  <tr>
    <td class="tg-yw4l">Continuous Bag of Words (CBOW) Text Classifier</td>
    <td class="tg-yw4l">Build a continuous bag of words text classifier.</td>
    <td class="tg-yw4l"><a href="https://colab.research.google.com/drive/1lqS67-mbCspIKzx6y9wn7CuP96utWzP2?usp=sharing">
  <img src="https://colab.research.google.com/assets/colab-badge.svg" width = '' >
</a></td>
  </tr>
  
  <tr>
    <td class="tg-yw4l">Deep Continuous Bag of Words (Deep CBOW) Text Classifier</td>
    <td class="tg-yw4l">Build a deep continuous bag of words text classifier.</td>
    <td class="tg-yw4l"><a href="https://colab.research.google.com/drive/18yz-qvMQYIYZt1BLihSJrKQZXh8zjH8x?usp=sharing">
  <img src="https://colab.research.google.com/assets/colab-badge.svg" width = '' >
</a></td>
  </tr>
 
  
  <tr>
    <td class="tg-yw4l">Text Data Augmentation</td>
    <td class="tg-yw4l">An introduction to the most commonly used data augmentation techniques for text and their implementation</td>
    <td class="tg-yw4l"><a href="https://colab.research.google.com/drive/1kyLaRevVf7VVy9BxJBJaL_ET4wyKSi-S?usp=sharing">
  <img src="https://colab.research.google.com/assets/colab-badge.svg" width = '' >
</a></td>
  </tr>  
  
  <tr>
    <td class="tg-yw4l">Emotion Classification with Fine-tuned BERT</td>
    <td class="tg-yw4l">Emotion classification using fine-tuned BERT model</td>
    <td class="tg-yw4l"><a href="https://colab.research.google.com/drive/1nwCE6b9PXIKhv2hvbqf1oZKIGkXMTi1X?usp=sharing">
  <img src="https://colab.research.google.com/assets/colab-badge.svg" width = '' >
</a></td>
  </tr>
  
  </table> 

## Transformers
 <table class="tg"> 
  
  <tr>
    <th class="tg-yw4l"><b>Name</b></th>
    <th class="tg-yw4l"><b>Description</b></th>
    <th class="tg-yw4l"><b>Notebook</b></th>
  </tr>
  
   <tr>
    <td class="tg-yw4l">Text Classification using Transformer</td>
    <td class="tg-yw4l">An implementation of Attention Mechanism and Positional Embeddings on a text classification  task</td>
    <td class="tg-yw4l"><a href="https://colab.research.google.com/drive/1Jc-_kcO3xYHDMFYSsIcUimcc38_WFlyh?usp=sharing">
  <img src="https://colab.research.google.com/assets/colab-badge.svg" width = '' >
</a><br>
      <a href="https://www.kaggle.com/code/ritvik1909/text-classification-attention" target="_blank"><img align="left" alt="Kaggle" title="Open in Kaggle" src="https://kaggle.com/static/images/open-in-kaggle.svg"></a></td>
  </tr>

   <tr>
    <td class="tg-yw4l">Neural Machine Translation using Transformer</td>
    <td class="tg-yw4l">An implementation of Transformer to translate human readable dates in any format to YYYY-MM-DD format.</td>
    <td class="tg-yw4l"><a href="https://colab.research.google.com/drive/1Y6JhWMmgU52MU9vyrOnHf6iK760Qx35h?usp=sharing">
  <img src="https://colab.research.google.com/assets/colab-badge.svg" width = '' >
</a><br>
     <a href="https://www.kaggle.com/code/ritvik1909/neural-machine-translation-attention" target="_blank"><img align="left" alt="Kaggle" title="Open in Kaggle" src="https://kaggle.com/static/images/open-in-kaggle.svg"></a></td>
  </tr>   

   <tr>
    <td class="tg-yw4l">Feature Tokenizer Transformer</td>
    <td class="tg-yw4l">An implementation of Feature Tokenizer Transformer on a classification task</td>
    <td class="tg-yw4l"><a href="https://colab.research.google.com/drive/1tdPifaZCTVpjzCh1FOyGPywMEfrbBZLh?usp=sharing">
  <img src="https://colab.research.google.com/assets/colab-badge.svg" width = '' >
</a><br>
     <a href="https://www.kaggle.com/code/ritvik1909/feature-tokenizer-transformer/" target="_blank"><img align="left" alt="Kaggle" title="Open in Kaggle" src="https://kaggle.com/static/images/open-in-kaggle.svg"></a></td>
  </tr>     

   <tr>
    <td class="tg-yw4l">Named Entity Recognition using Transformer</td>
    <td class="tg-yw4l">An implementation of Transformer to perform token classification and identify species in PubMed abstracts</td>
    <td class="tg-yw4l"><a href="https://colab.research.google.com/drive/12AdzQuOvFMrhlVI92dfaVpttkgBcgWcf?usp=sharing">
  <img src="https://colab.research.google.com/assets/colab-badge.svg" width = '' >
</a><br>
     <a href="https://www.kaggle.com/code/ritvik1909/named-entity-recognition-attention" target="_blank"><img align="left" alt="Kaggle" title="Open in Kaggle" src="https://kaggle.com/static/images/open-in-kaggle.svg"></a></td>
  </tr>   
  
   <tr>
    <td class="tg-yw4l">Extractive Question Answering using Transformer</td>
    <td class="tg-yw4l">An implementation of Transformer to perform extractive question answering</td>
    <td class="tg-yw4l"><a href="https://colab.research.google.com/drive/1Eq3PkrItGTZMTww-wlzume2j4nkQYsdP?usp=sharing">
  <img src="https://colab.research.google.com/assets/colab-badge.svg" width = '' >
</a><br>
     <a href="https://www.kaggle.com/code/ritvik1909/question-answering-attention/" target="_blank"><img align="left" alt="Kaggle" title="Open in Kaggle" src="https://kaggle.com/static/images/open-in-kaggle.svg"></a></td>
  </tr>    
 </table> 
 
## Computer Vision

<table class="tg">
  <tr>
    <th class="tg-yw4l"><b>Name</b></th>
    <th class="tg-yw4l"><b>Description</b></th>
    <th class="tg-yw4l"><b>Notebook</b></th>
  </tr>
  <tr>
    <td class="tg-yw4l">Siamese Network</td>
    <td class="tg-yw4l">An implementation of Siamese Network for finding Image Similarity</td>
    <td class="tg-yw4l"><a href="https://colab.research.google.com/drive/1sn7BDKVvi8-Ng37gvfyNw8OCf8kZY91o?usp=sharing">
  <img src="https://colab.research.google.com/assets/colab-badge.svg" width = '' >
</a><br>
     <a href="https://kaggle.com/code/ritvik1909/siamese-network" target="_blank"><img align="left" alt="Kaggle" title="Open in Kaggle" src="https://kaggle.com/static/images/open-in-kaggle.svg"></a></td>
  </tr>  

   <tr>
    <td class="tg-yw4l">Variational Auto Encoder</td>
    <td class="tg-yw4l">An implementation of Variational Auto Encoder to generate Augmentations for MNIST Handwritten Digits</td>
    <td class="tg-yw4l"><a href="https://colab.research.google.com/drive/13na-qaRSMwD2jplXjg_oapPDmVozIzLL?usp=sharing">
  <img src="https://colab.research.google.com/assets/colab-badge.svg" width = '' >
</a><br>
     <a href="https://www.kaggle.com/code/ritvik1909/variational-auto-encoder" target="_blank"><img align="left" alt="Kaggle" title="Open in Kaggle" src="https://kaggle.com/static/images/open-in-kaggle.svg"></a></td>
  </tr>    

   <tr>
    <td class="tg-yw4l">Object Detection using Sliding Window and Image Pyramid</td>
    <td class="tg-yw4l">A basic object detection implementation using sliding window and image pyramid on top of an image classifier</td>
    <td class="tg-yw4l"><a href="https://colab.research.google.com/drive/1CiLN6g7puBheHq-tfk4YB4X-Lgypur8M?usp=sharing">
  <img src="https://colab.research.google.com/assets/colab-badge.svg" width = '' >
</a><br>
     <a href="https://www.kaggle.com/code/ritvik1909/object-detection-sliding-window" target="_blank"><img align="left" alt="Kaggle" title="Open in Kaggle" src="https://kaggle.com/static/images/open-in-kaggle.svg"></a></td>
  </tr>    
  
   <tr>
    <td class="tg-yw4l">Object Detection using Selective Search</td>
    <td class="tg-yw4l">A basic object detection implementation using selective search on top of an image classifier</td>
    <td class="tg-yw4l"><a href="https://colab.research.google.com/drive/1C7Zo5JRMrcETMxn-8jRuszrEXXjRbN37?usp=sharing">
  <img src="https://colab.research.google.com/assets/colab-badge.svg" width = '' >
</a><br>
     <a href="https://www.kaggle.com/code/ritvik1909/object-detection-selective-search" target="_blank"><img align="left" alt="Kaggle" title="Open in Kaggle" src="https://kaggle.com/static/images/open-in-kaggle.svg"></a></td>
  </tr>  
  
</table> 

## Generative Adversarial Network
<table class="tg">
  <tr>
    <th class="tg-yw4l"><b>Name</b></th>
    <th class="tg-yw4l"><b>Description</b></th>
    <th class="tg-yw4l"><b>Notebook</b></th>
  </tr>
  <tr>
    <td class="tg-yw4l">Deep Convolutional GAN</td>
    <td class="tg-yw4l">An Implementation of Deep Convolutional GAN to generate MNIST digits</td>
    <td class="tg-yw4l"><a href="https://colab.research.google.com/drive/1ss9FCHvI0ZAuS1PJL6RxlgEhM_glZR6S?usp=sharing">
  <img src="https://colab.research.google.com/assets/colab-badge.svg" width = '' >
</a><br>
     <a href="https://www.kaggle.com/code/ritvik1909/deep-convolutional-gan/" target="_blank"><img align="left" alt="Kaggle" title="Open in Kaggle" src="https://kaggle.com/static/images/open-in-kaggle.svg"></a></td>
  </tr>  
  <tr>
    <td class="tg-yw4l">Wasserstein GAN with Gradient Penalty</td>
    <td class="tg-yw4l">An Implementation of Wasserstein GAN with Gradient Penalty to generate MNIST digits</td>
    <td class="tg-yw4l"><a href="https://colab.research.google.com/drive/1x7aDlxkv3PYev2AsmZRl8pII2zsY_DVs?usp=sharing">
  <img src="https://colab.research.google.com/assets/colab-badge.svg" width = '' >
</a><br>
     <a href="https://www.kaggle.com/code/ritvik1909/wasserstein-gan-with-gradient-penalty/" target="_blank"><img align="left" alt="Kaggle" title="Open in Kaggle" src="https://kaggle.com/static/images/open-in-kaggle.svg"></a></td>
  </tr>  
  <tr>
    <td class="tg-yw4l">Conditional GAN</td>
    <td class="tg-yw4l">An Implementation of Conditional GAN to generate MNIST digits</td>
    <td class="tg-yw4l"><a href="https://colab.research.google.com/drive/1Z74CpEu76e6A62gxKXIJ8u8xyVjF21_k?usp=sharing">
  <img src="https://colab.research.google.com/assets/colab-badge.svg" width = '' >
</a><br>
     <a href="https://www.kaggle.com/code/ritvik1909/conditional-gan/" target="_blank"><img align="left" alt="Kaggle" title="Open in Kaggle" src="https://kaggle.com/static/images/open-in-kaggle.svg"></a></td>
  </tr>  
  
</table>
 
 
---

If you find any bugs or have any questions regarding these notebooks, please open an issue. We will address it as soon as we can. 

Reach out on [Twitter](https://twitter.com/omarsar0) if you have any questions. 

Please cite the following if you use the code examples in your research:

```
@misc{saravia2022ml,
  title={ML Notebooks},
  author={Saravia, Elvis and Rastogi, Ritvik},
  journal={https://github.com/dair-ai/ML-Notebooks},
  year={2022}
}
```
