All Projects → RMichaelSwan → MogrifierLSTM

RMichaelSwan / MogrifierLSTM

Licence: MIT License
A quick walk-through of the innards of LSTMs and a naive implementation of the Mogrifier LSTM paper in PyTorch

Programming Languages

Jupyter Notebook
11667 projects

Projects that are alternatives of or similar to MogrifierLSTM

colab-badge-action
GitHub Action that generates "Open In Colab" Badges for you
Stars: ✭ 15 (-74.14%)
Mutual labels:  notebook, google-colaboratory
Pytorch Ntm
Neural Turing Machines (NTM) - PyTorch Implementation
Stars: ✭ 453 (+681.03%)
Mutual labels:  notebook, lstm
vnote
A dairy note edit and manage tool in vim
Stars: ✭ 17 (-70.69%)
Mutual labels:  notebook
vertex-ai-samples
Sample code and notebooks for Vertex AI, the end-to-end machine learning platform on Google Cloud
Stars: ✭ 270 (+365.52%)
Mutual labels:  notebook
CharLSTM
Bidirectional Character LSTM for Sentiment Analysis - Tensorflow Implementation
Stars: ✭ 49 (-15.52%)
Mutual labels:  lstm
pytest-notebook
A pytest plugin for regression testing and regenerating Jupyter Notebooks
Stars: ✭ 35 (-39.66%)
Mutual labels:  notebook
SoH estimation of Lithium-ion battery
State of health (SOH) prediction for Lithium-ion batteries using regression and LSTM
Stars: ✭ 28 (-51.72%)
Mutual labels:  lstm
object-tracking
Multiple Object Tracking System in Keras + (Detection Network - YOLO)
Stars: ✭ 89 (+53.45%)
Mutual labels:  lstm
dmind
jupyter notebook 的思维导图插件
Stars: ✭ 21 (-63.79%)
Mutual labels:  notebook
Learning-Lab-C-Library
This library provides a set of basic functions for different type of deep learning (and other) algorithms in C.This deep learning library will be constantly updated
Stars: ✭ 20 (-65.52%)
Mutual labels:  lstm
torch-lrcn
An implementation of the LRCN in Torch
Stars: ✭ 85 (+46.55%)
Mutual labels:  lstm
Baby-Action-Detection-for-Safety-System-Prototype
Prototype for Baby Action Detection and Classification
Stars: ✭ 23 (-60.34%)
Mutual labels:  lstm
Robust-Deep-Learning-Pipeline
Deep Convolutional Bidirectional LSTM for Complex Activity Recognition with Missing Data. Human Activity Recognition Challenge. Springer SIST (2020)
Stars: ✭ 20 (-65.52%)
Mutual labels:  lstm
SemEval2019Task3
Code for ANA at SemEval-2019 Task 3
Stars: ✭ 41 (-29.31%)
Mutual labels:  lstm
SentimentAnalysis
Sentiment Analysis: Deep Bi-LSTM+attention model
Stars: ✭ 32 (-44.83%)
Mutual labels:  lstm
Manhattan-LSTM
Keras and PyTorch implementations of the MaLSTM model for computing Semantic Similarity.
Stars: ✭ 28 (-51.72%)
Mutual labels:  lstm
Intelligent-Bangla-typing-assistant
Artificially intelligent typing assistant that suggest the next word using user typing history and full sentence using LSTM . Works with any environment (MS word, notepad, coding IDEs or anything)
Stars: ✭ 13 (-77.59%)
Mutual labels:  lstm
flawesome
Productivity Tool
Stars: ✭ 56 (-3.45%)
Mutual labels:  notebook
Base-On-Relation-Method-Extract-News-DA-RNN-Model-For-Stock-Prediction--Pytorch
基於關聯式新聞提取方法之雙階段注意力機制模型用於股票預測
Stars: ✭ 33 (-43.1%)
Mutual labels:  lstm
oceanpress
将 Markdown 文件转换为 HTML 生成静态站点的工具,专为思源笔记实现了许多特有渲染效果。
Stars: ✭ 61 (+5.17%)
Mutual labels:  notebook

Mogrifier LSTM

This repository implements an LSTM from scratch in PyTorch (allowing PyTorch to handle the backpropagation step) and then attempts to replicate the Mogrifier LSTM paper. The code can be run locally or in Google Colaboratory.

Update: The code for the mogrifier LSTM has been posted. It's a bit hard to grok due to way they parameterized their neural network model experiments, so I will attempt to update my own implementation for correctness, but if you want to go to the source, look here

Mogrifier LSTM Results

I tested the Mogrifier LSTM on a basic RNN text prediction problem using the Brown corpus dataset (more info in the notebook) and saw earlier convergence results and slightly better validation and training loss results when comparing the Mogrifier LSTM to a vanilla LSTM. To further verify these results, we need to test against more datasets and more neural network architectures. Checkpoints and metrics have been saved for each LSTM type per epoch (see run folder); I didn't CM the tensorboard event logs as they are huge, but you can get most of the same information just looking at the JSON metric files. A summary of the results I got can be seen below:

LSTM validation loss comparison

My LSTM (made from scratch; slow)

automatic early stopping never reached criteria for stop in 210 epochs, though may have been close


 'best_epoch': 207,
 'training_epochs': 209,
 'epoch': 209,
 'training_loss': 1.3781935724280996,
 'training_cpu_memory_MB': 2750.236,
 'training_gpu_0_memory_MB': 952,
 'validation_loss': 1.401858257619958,
 'best_validation_loss': 1.4012448003417568}

Official PyTorch LSTM (has optimized performance)

automatic early stopping used


 'best_epoch': 197,
 'training_epochs': 203,
 'epoch': 203,
 'training_loss': 1.3790437656746815,
 'training_cpu_memory_MB': 2751.964,
 'training_gpu_0_memory_MB': 1014,
 'validation_loss': 1.4007186230860258,
 'best_validation_loss': 1.4002491518070823

Mogrifier LSTM (used my LSTM and then added improvements)

automatic early stopping used


 'best_epoch': 141
 'training_epochs': 147,
 'epoch': 147,
 'training_loss': 1.3751222530060265,
 'training_cpu_memory_MB': 2771.636,
 'training_gpu_0_memory_MB': 1115,
 'validation_loss': 1.401227615381542,
 'best_validation_loss': 1.3973440904366343

Note on Mogrifier results: The Mogrifier LSTM paper claimed they would release their own code, but this has yet to happen (paper was released in September 2019). When that code is available, it should be at https://github.com/deepmind/lamb .

Running the Code Yourself

There are a couple of ways to run the code in this repository. One method is to run in a Jupyter notebook locally. The other method is to upload the notebook file to Google Colaboratory and run from there. The second method is convenient, but may not give you all the training time you really want. Instructions for both methods are found below.

Local Install

Recommended you use Python 3.7. You will need to make sure that your virtualenv setup is of the correct version of python. We will be using PyTorch.

Please see below for executing a virtual environment.

cd MogrifierLSTM
pip3 install virtualenv # If you didn't install it
virtualenv -p $(which python3) ./venv_lstm
source ./venv_lstm/bin/activate

# Install dependencies
pip3 install -r requirements.txt

# View the notebook

# Deactivate the virtual environment when you are done
deactivate

Working with IPython Notebook

To view the notebook, simply run the following command to start an ipython kernel.

# add your virtual environment to jupyter notebook
python -m ipykernel install --user --name=venv_lstm

# port is only needed if you want to work on more than one notebook
jupyter notebook --port=<your_port>

and then work on the MogrifierLSTM.ipynb notebook. Check the python environment you are using on the top right corner. If the name of environment doesn't match, change it to your virtual environment in "Kernel>Change kernel".

Viewing the results in tensorboard

After running your own training runs and collecting all your event logs, you can see the results in tensorboard by running the following command in a terminal and then viewing the link provided in your browser.

#replace "run" with whatever directory you have saved 
#your runs to (if different than what was set in the notebook) 
tensorboard --logdir run

Cloud Install (Google Colaboratory)

  1. Head over to Google Colab. It is recommended that you switch to a GPU notebook as things will usually run a little faster that way. There are instructions for this on the colaboratory site.
  2. Download the .ipynb file in this repository
  3. Upload that file to Google Colabatory and run from there!

Note: Google Colaboratory has time limits for their systems, so you may not be able to fully train the Mogrifier LSTM on their system without some special effort.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].