Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

Anirudh Vemula vvanirudh

💭
I may be slow to respond.
View GitHub Profile
@vvanirudh
vvanirudh / auto_git_file.md
Created Feb 6, 2021 — forked from darencard/auto_git_file.md
Automatic file git commit/push upon change
View auto_git_file.md

Automatically push an updated file whenever it is changed

Linux

  1. Make sure inotify-tools is installed (https://github.com/rvoicilas/inotify-tools)
  2. Configure git as usual
  3. Clone the git repository of interest from github and, if necessary, add file you want to monitor
  4. Allow username/password to be cached so you aren't asked everytime
git config credential.helper store
@vvanirudh
vvanirudh / test_pr2_pick.py
Created Jul 3, 2020
Example of PR2 grasping an object using ss-pybullet
View test_pr2_pick.py
#!/usr/bin/env python
from __future__ import print_function
import numpy as np
import pybullet as p
from pybullet_tools.utils import (connect, disable_real_time,
set_default_camera, wait_for_user,
disconnect, load_pybullet, TABLE_URDF, add_data_path,
create_box, FLOOR_URDF, set_point, load_model,
HideOutput, set_base_values, get_unit_vector, WorldSaver,
@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 Mar 22, 2021
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