Skip to content

Instantly share code, notes, and snippets.

View chmodsss's full-sized avatar
🎵

Sivasurya Santhanam chmodsss

🎵
View GitHub Profile
@chmodsss
chmodsss / fine_tune_glove.py
Created April 19, 2020 06:26
Fine tuning glove embeddings using Mittens
import csv
import numpy as np
from collections import Counter
from nltk.corpus import brown
from mittens import GloVe, Mittens
from sklearn.feature_extraction import stop_words
from sklearn.feature_extraction.text import CountVectorizer
def glove2dict(glove_filename):
@chmodsss
chmodsss / gan_mnist.py
Created January 3, 2020 22:37
Generative Adversarial network using pytorch
import torch
from torchvision.datasets import MNIST
from torch import nn
from torchvision import transforms
import torch.optim as optim
from matplotlib import pyplot as plt
import matplotlib.cm as cm
import warnings
warnings.filterwarnings("ignore")
@chmodsss
chmodsss / disc_genr.py
Created December 30, 2019 19:16
Discriminator Generator in GAN
class Discriminator(nn.Module):
def __init__(self):
super().__init__()
ip_emb = 784
emb1 = 256
emb2 = 128
out_emb = 1
self.layer1 = nn.Sequential(
@chmodsss
chmodsss / textgen_onehot.py
Created September 18, 2018 12:58
Text generation 2
import collections
import pandas as pd
import numpy as np
sents = [s for s in cdata.split()]
vocab = sorted(collections.Counter(sents))
vocab2idx = {v:idx for idx,v in enumerate(vocab)}
idx2vocab = {idx:v for idx,v in enumerate(vocab)}
@chmodsss
chmodsss / textgen_data_prep.py
Created September 18, 2018 09:19
Text generation 1
import string
puncts = string.punctuation.replace('.','')
punct = str.maketrans('','', puncts)
data = open('story.txt','r').read()
# data pre-processing only for alphabet strings
def clean(xx):
return ' '.join(x for x in xx.split() if not x.isnumeric())
@chmodsss
chmodsss / tetris.ipynb
Created August 29, 2018 22:58
tetris.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import pandas as pd
import numpy as np
from sklearn.datasets import load_digits
from sklearn.model_selection import train_test_split
dig = load_digits()
onehot_target = pd.get_dummies(dig.target)
x_train, x_val, y_train, y_val = train_test_split(dig.data, onehot_target, test_size=0.1, random_state=20)
def sigmoid(s):
import pandas as pd
from keras.layers import Dense
from keras.models import Sequential
from keras.optimizers import RMSprop, Adadelta, Adam
from sklearn.datasets import load_digits
from sklearn.model_selection import train_test_split
dig = load_digits()
onehot_target = pd.get_dummies(dig.target)
x_train, x_val, y_train, y_val = train_test_split(dig.data, onehot_target, test_size=0.1, random_state=20)
@chmodsss
chmodsss / nn_dataprep.py
Created August 16, 2018 16:40
NN from scratch. data preparation
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.datasets import load_digits
from sklearn.model_selection import train_test_split
%matplotlib inline
dig = load_digits()
plt.gray()
plt.matshow(dig.images[25])
@chmodsss
chmodsss / copy_svnprop.sh
Created December 15, 2016 08:51
Bash script to copy svn properties between two different repositories.
#!/bin/sh
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
SRC_PATH=path/to/source/folder
DST_PATH=path/to/destination/folder
for src_dir in $(ls $SRC_PATH)
do
for src_file in $(ls $SRC_PATH/$src_dir)
do
src_fpath=$SRC_PATH/$src_dir/$src_file