Skip to content

Instantly share code, notes, and snippets.

💭
I may be slow to respond.

Anirudh Vemula vvanirudh

💭
I may be slow to respond.
Block or report user

Report or block vvanirudh

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@vvanirudh
vvanirudh / natural_grad.py
Created Feb 15, 2019
Natural Gradient Demo
View natural_grad.py
import numpy as np
from sklearn.utils import shuffle
import random
import argparse
import matplotlib.pyplot as plt
import time
parser = argparse.ArgumentParser()
parser.add_argument('--ng', action='store_true')
parser.add_argument('--seed', type=int, default=10)
@vvanirudh
vvanirudh / runningstat.py
Created Mar 30, 2018
Running mean and standard deviation
View runningstat.py
# From https://www.johndcook.com/blog/standard_deviation/
# and https://github.com/modestyachts/ARS
class RunningStat(object):
def __init__(self, shape=None):
self._n = 0
self._M = np.zeros(shape, dtype = np.float64)
self._S = np.zeros(shape, dtype = np.float64)
self._M2 = np.zeros(shape, dtype = np.float64)
View draw_convnet.py
"""
Copyright (c) 2017, Gavin Weiguang Ding
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
@vvanirudh
vvanirudh / Keeping a fork up to date
Last active Feb 28, 2018 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date
View Keeping a fork up to date
### 1. Clone your fork:
git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git
### 2. Add remote from original repository in your forked repository:
cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@vvanirudh
vvanirudh / sliding_mean.py
Created Feb 6, 2018
Computing sliding mean to smooth curves
View sliding_mean.py
import numpy as np
def sliding_mean(data_array, window=5):
data_array = np.array(data_array)
new_list = []
for i in range(len(data_array)):
indices = range(max(i - window + 1, 0),
min(i + window + 1, len(data_array)))
avg = 0
for j in indices:
@vvanirudh
vvanirudh / random_fourier_features.py
Created Feb 6, 2018
Random fourier features using both sines and cosines embedding for Gaussian kernel
View random_fourier_features.py
from sklearn.base import BaseEstimator
from sklearn.exceptions import NotFittedError
import numpy as np
class IRFF(BaseEstimator):
'''
Random fourier features using the improved embedding
https://www.cs.cmu.edu/~schneide/DougalRandomFeatures_UAI2015.pdf
'''
@vvanirudh
vvanirudh / bayes_by_backprop.py
Last active Dec 6, 2019
Bayes by Backprop in PyTorch (introduced in the paper "Weight uncertainty in Neural Networks", Blundell et. al. 2015)
View bayes_by_backprop.py
# Drawn from https://gist.github.com/rocknrollnerd/c5af642cf217971d93f499e8f70fcb72 (in Theano)
# This is implemented in PyTorch
# Author : Anirudh Vemula
import torch
import torch.nn as nn
from torch.autograd import Variable
import numpy as np
from sklearn.datasets import fetch_mldata
@vvanirudh
vvanirudh / gan_1d.py
Created Apr 26, 2017
GAN to model a 1D gaussian distribution
View gan_1d.py
# Drawn from https://gist.github.com/rocknrollnerd/06bfed6b9d1bce612fd6 (in theano)
# This is implemented in PyTorch
# Author : Anirudh Vemula
import numpy as np
import torch
import torch.nn as nn
from torch.autograd import Variable
from scipy.stats import norm
import matplotlib.pyplot as plt
You can’t perform that action at this time.