Skip to content

Instantly share code, notes, and snippets.

View reddragon's full-sized avatar
🤖
Too much to do, too little time.

Gaurav Menghani reddragon

🤖
Too much to do, too little time.
View GitHub Profile
#include <iostream>
using namespace std;
struct Node {
int val;
Node *next;
};
void print(Node* n) {
@reddragon
reddragon / linear_regression.py
Created April 5, 2017 08:31
Linear Regression in Python
'''
Linear Regression From First Principles
Author: Gaurav Menghani (gaurav.menghani@gmail.com)
'''
import numpy as np
import matplotlib.pyplot as plt
def linear_sum(X, W, b):
return X.dot(W) + b
@reddragon
reddragon / pet-projects.md
Created April 21, 2017 00:59
List of Possible Pet Projects
  1. embeddings.js: word2vec in Javascript
import torch
import torchvision
import torch.nn as nn
import torch.nn.functional as F
import torchvision.transforms as transforms
import matplotlib.pyplot as plt
import numpy as np
import torch.optim as optim
from torch.autograd import Variable
@reddragon
reddragon / pong-next20-data.py
Created April 30, 2017 06:43
Predicting whether there would be a goal in the next 20 steps in the ATARI Pong Game
import gym
import logging
import sys
import numpy as np
from gym import wrappers
import torch
import torchvision
import torch.nn as nn
import torch.nn.functional as F
@reddragon
reddragon / cart-pole-pg.py
Created May 8, 2017 17:33
CartPole for the OpenAI gym using Policy Gradients
import gym
import logging
import sys
import numpy as np
from gym import wrappers
import torch
import torchvision
import torch.nn as nn
import torch.nn.functional as F
@reddragon
reddragon / cart-pole-pg-v2.py
Created May 8, 2017 18:32
Slightly tweaked PG for CartPole #dogscience
import gym
import logging
import sys
import numpy as np
from gym import wrappers
import torch
import torchvision
import torch.nn as nn
import torch.nn.functional as F
@reddragon
reddragon / script.py
Created May 29, 2017 07:19
Get all of those graduation pics
import os
import sys
import urllib2
def normalize_path(path):
if path[-1] == '/':
path = path[:-1]
return path
def get_dir_name(path):
@reddragon
reddragon / frozen-lake-iterative.py
Created June 11, 2017 17:12
Frozen Lake solved using the Q-Learning algorithm with an actual Q-value table
import gym
import logging
import sys
import numpy as np
from gym import wrappers
SEED = 0
NUM_EPISODES = 3000
# Hyperparams
@reddragon
reddragon / frozen-lake-nn.py
Created June 12, 2017 23:11
Frozen Lake NN Implementation
import gym
import logging
import sys
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import cPickle as pickle
import os