Skip to content

Instantly share code, notes, and snippets.

View djsaunde's full-sized avatar

Dan Saunders djsaunde

View GitHub Profile
def add_accelerate_options():
"""Create Click options from accelerate's launch command arguments."""
def decorator(function):
parser = launch_command_parser()
# Process each argument group in reverse order for correct option ordering
for group in reversed(parser._action_groups):
if group.title in ['positional arguments', 'optional arguments']:
continue
@djsaunde
djsaunde / mh_mcmc.py
Last active March 14, 2019 15:22
Simple Metropolis-Hastings MCMC implementation with a Gaussian proposal distribution.
import argparse
import scipy.stats
import numpy as np
import matplotlib.cm as cm
import matplotlib.pyplot as plt
from tqdm import tqdm
from matplotlib.patches import Ellipse
@djsaunde
djsaunde / LIFNodes vs. CurrentLIFNodes.ipynb
Created June 11, 2018 13:53
Comparison of simple voltage-based and current-based LIF neurons
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@djsaunde
djsaunde / cartpole.py
Created August 9, 2017 20:55
PyTorch Cartpole
'''
PyTorch tutorial code found at http://pytorch.org/tutorials/intermediate/reinforcement_q_learning.html#sphx-glr-intermediate-reinforcement-q-learning-py.
'''
import gym
import math
import random
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
@djsaunde
djsaunde / tensorflow_mnist_tutorial.py
Last active December 14, 2016 05:08
Taking the code from the TensorFlow tutorial here: https://www.tensorflow.org/tutorials/mnist/pros/, and cleaning it up a tiny bit.
# coding: utf-8
# imports
from tensorflow.examples.tutorials.mnist import input_data
import tensorflow as tf
# download and store MNIST data
mnist = input_data.read_data_sets('MNIST_data', one_hot=True)
# create TensorFlow interactive session