Skip to content

Instantly share code, notes, and snippets.

View singhay's full-sized avatar
🐢
Exciting times!

Ayush Singh singhay

🐢
Exciting times!
View GitHub Profile
# This is script is limited to single GPU at the moment due to LSH attention approximation
import argparse
import glob
import logging
import os
from typing import Dict, List
import torch
from reformer_pytorch import ReformerLM
from tokenizers import ByteLevelBPETokenizer
@singhay
singhay / conv lstm model.py
Last active July 4, 2018 19:23
Timedistribued Flatten after Timedistributed add throws symbolic tensor instance error
def get_model():
input_image_seqs = Input(shape=(None, 32, 32, 1), name='input_image_seqs')
bn1 = BatchNormalization()(input_image_seqs)
ac1 = Activation('elu')(bn1)
conv1 = TimeDistributed(Conv2D(32, (3, 3), strides=(1, 1), activation='elu', padding='same'))(ac1)
bn2 = BatchNormalization()(conv1)
ac2 = Activation('elu')(bn2)
conv2 = TimeDistributed(Conv2D(32, (3, 3), strides=(1, 1), activation='elu', padding='same'))(ac2)
@singhay
singhay / sentiment.py
Created February 28, 2018 03:56 — forked from schinazi/sentiment.py
An end-to-end demonstration of a Scikit-Learn SVM classifier trained on the positive and negative movie reviews corpus in NLTK.
import os
import time
import string
import pickle
from operator import itemgetter
from nltk.corpus import stopwords as sw
from nltk.corpus import wordnet as wn
from nltk import wordpunct_tokenize
@singhay
singhay / live_loss_plot_keras.ipynb
Created December 7, 2017 06:07 — forked from stared/live_loss_plot_keras.ipynb
Live loss plot for training models in Keras
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@singhay
singhay / pca.py
Created March 27, 2016 02:19
Cute fish out of MNIST Handwritten Dataset [OC]
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.decomposition import PCA
'''
https://www.reddit.com/r/dataisbeautiful/comments/4c3zjt/cute_fish_out_of_mnist_handwritten_dataset_oc/
PCA Dimentionality Reduction of Handwritten Dataset from 784 to 2, normalizing and vizualizing.
'''
def main():
@singhay
singhay / Simplified_SMO.py
Created February 28, 2016 09:17
A Simplified Support Vector Machine Sequential minimal optimization Algorithm
# Inspired from http://cs229.stanford.edu/materials/smo.pdf
import os
import numpy as np
import pandas as pd
import math
from sklearn.svm import LinearSVC
from sklearn.metrics import accuracy_score
def SMO(data, classLabel, constant, tolerance, maxpasses):
dataMatrix = np.array(data)