Skip to content

Instantly share code, notes, and snippets.

Will Whitney willwhitney

Block or report user

Report or block willwhitney

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
View test_data.json
class DmMujocoModel(nn.Module):
def __init__(self, embed_dim, env_name, traj_len, qpos_only=False, qpos_qvel=False):
self.embed_dim = embed_dim
self.dataset = DmData(env_name, traj_len, qpos_only, qpos_qvel)
self.env = self.dataset.env
self.dummy_parameter = nn.Parameter(torch.zeros(1))
def forward(self, s, a):
willwhitney /
Created Aug 24, 2018
Fragment of python code for catching signals from Slurm and restarting the job
import signal
# depends on requesting SIGUSR1 in runner file:
def handle_signal(signal_value, _):
signame = signal.Signals(signal_value).name
if signal_value == signal.SIGUSR1:
print('Process {} got signal {}. Saving and restarting.'.format(
os.getpid(), signame), flush=True)
willwhitney /
Created Jul 10, 2018
load tensorboard log files into pandas dataframes
from tensorboard.backend.event_processing import event_accumulator
import tensorflow as tf
import glob
import pandas as pd
basedir = "/path/to/log/directory/"
def load_tf(dirname):
prefix = basedir + "tboard/VisibleSwimmer-v2/"
willwhitney /
Last active Apr 24, 2019
Script for running grids of experiments on slurm
# things to change:
# code_dir (the full path of the directory that contains your source dir)
# true_source_dir (change it from TD3 to whatever your source dir is called)
# job_source_dir (someplace to throw a duplicate of the source dir for this job)
import os
import sys
import itertools
View unable_to_open.txt
File "", line 56, in <module>
parents = random.choices(population, scores + 1e-10, k=pop_size)
File "/home/wwhitney/anaconda3/lib/python3.6/multiprocessing/", line 260, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File "/home/wwhitney/anaconda3/lib/python3.6/multiprocessing/", line 608, in get
raise self._value
multiprocessing.pool.MaybeEncodingError: Error sending result:
<my object>
Reason: 'RuntimeError('unable to open shared memory object </torch_29253_1584213566> in read-write mode at /py/conda-bld/pytorch_1493680494901/work/torch/lib/TH/THAllocator.c:226',)'
View mmap_0GB.txt
Traceback (most recent call last):
File "/home/wwhitney/anaconda3/lib/python3.6/multiprocessing/", line 249, in _bootstrap
File "/home/wwhitney/anaconda3/lib/python3.6/multiprocessing/", line 93, in run
self._target(*self._args, **self._kwargs)
File "/home/wwhitney/anaconda3/lib/python3.6/multiprocessing/", line 108, in worker
task = get()
File "/home/wwhitney/anaconda3/lib/python3.6/multiprocessing/", line 345, in get
return _ForkingPickler.loads(res)
File "/home/wwhitney/anaconda3/lib/python3.6/site-packages/torch/multiprocessing/", line 86, in rebuild_storage_filename
willwhitney / propublica_per_capita.js
Last active May 13, 2016
Getting per-state per capita usage numbers from with jank javascript.
View propublica_per_capita.js
To use me, go to one of the individual drug pages from propublica (e.g.,
open the console (press ⌘-⌥-J on Mac),
paste in this script and hit Enter.
A new column should appear in your table.
This is very much hacked together in the console, so... no guarantees it will work next week.
states = [[1, "California", 39144818],
willwhitney /
Last active Oct 27, 2017 — forked from celoyd/
Fetch and untile tiled Himawari-8 images from the PNG endpoint, then set them as desktop background on OSX
import requests
import sys
from datetime import datetime, timedelta
import pytz
from PIL import Image
from StringIO import StringIO
import os
import logging
# python
willwhitney / dirty.js
Last active Aug 29, 2015
a dirty private method
View dirty.js
publicMethods = ['bark']
class Dog {
constructor() {
_secret = new Dog();
_.forOwn(this, (value, key) => {
if (_.isFunction(value)) {
if (_.contains(publicMethods, key)) {
You can’t perform that action at this time.