This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Discriminator(nn.Module): | |
def __init__(self): | |
super().__init__() | |
ip_emb = 784 | |
emb1 = 256 | |
emb2 = 128 | |
out_emb = 1 | |
self.layer1 = nn.Sequential( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
NewerOlder