Skip to content

Instantly share code, notes, and snippets.

View thouis's full-sized avatar

Thouis (Ray) Jones thouis

  • Broad Institute
  • Cambridge, MA, USA
View GitHub Profile
import sys
import h5py
import numpy as np
def pygame(h5, name, board, moves):
for idx in range(board.shape[0]):
for plane in range(board.shape[1]):
if plane < 44:
# different board orderings
f = board[idx, plane, ...].T[:, ::-1]
@thouis
thouis / 0_reuse_code.js
Created May 12, 2016 01:28
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
import tensorflow as tf
from tensorflow.python import control_flow_ops
# from http://stackoverflow.com/a/34634291
def batch_norm(x, n_out, phase_train, scope='bn', affine=True):
"""
Batch normalization on convolutional maps.
Args:
x: Tensor, 4D BHWD input maps
n_out: integer, depth of input maps
@thouis
thouis / rand.py
Last active August 11, 2019 09:59
more straightforward adjusted rand error
# coding=utf-8
import numpy as np
import scipy.sparse as sparse
# Evaluation code courtesy of Juan Nunez-Iglesias, taken from
# https://github.com/janelia-flyem/gala/blob/master/gala/evaluate.py
def adapted_rand(seg, gt, all_stats=False):
"""Compute Adapted Rand error as defined by the SNEMI3D contest [1]
def depth_to_space(x, blocksize=2):
b, k, d, r, c = x.shape
r1 = x.reshape((b, k // (blocksize ** 2), blocksize, blocksize, d, r, c))
r2 = r1.transpose(0, 1, 4, 5, 2, 6, 3)
return r2.reshape((b, k // (blocksize ** 2), d, r * blocksize, c * blocksize))

Keybase proof

I hereby claim:

  • I am thouis on github.
  • I am thouis (https://keybase.io/thouis) on keybase.
  • I have a public key whose fingerprint is A4F6 3AF2 C0E4 8CAE 7501 2BDE 2904 0D09 3557 95A4

To claim this, I am signing this object:

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import sys
import twitter
import time
# see https://python-twitter.readthedocs.io/en/latest/getting_started.html
api = twitter.Api(consumer_key=CONSUMER_KEY,
consumer_secret=CONSUMER_SECRET,
access_token_key=ACCESS_TOKEN,
access_token_secret=ACCESS_SECRET)
@thouis
thouis / Players.ipynb
Last active January 2, 2020 20:17
OGS Player stats
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import os
from urllib import request
import numpy as np
import pandas as pd
# grab a large corpus of words, sorted by usage counts (Peter Norvig)
if not os.path.isfile('count_1w.txt'):
request.urlretrieve("https://norvig.com/ngrams/count_1w.txt",
"count_1w.txt")