Skip to content

Instantly share code, notes, and snippets.

Mathieu Blondel mblondel

View GitHub Profile
piscisaureus /
Created Aug 13, 2012
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url =

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

dwf / kmeans.pyx
Created Mar 25, 2012
Parallelized k-means in Cython.
View kmeans.pyx
Parallelized k-means module.
By David Warde-Farley, February 2012. Licensed under the 3-clause BSD.
cimport cython
from cython.parallel import prange
import numpy as np
cimport numpy as np
from numpy.random import normal
import tensorflow as tf
from tensorflow.python.framework import ops
import numpy as np
# Define custom py_func which takes also a grad op as argument:
def py_func(func, inp, Tout, stateful=True, name=None, grad=None):
# Need to generate a unique name to avoid duplicates:
rnd_name = 'PyFuncGrad' + str(np.random.randint(0, 1E+8))
paniq / minmaxabssign.txt
Last active Mar 23, 2020
useful min/max/abs/sign identities
View minmaxabssign.txt
max(-x,-y) = -min(x,y)
min(-x,-y) = -max(x,y)
abs(x) = abs(-x)
abs(x) = max(x,-x) = -min(x,-x)
abs(x*a) = if (a >= 0) abs(x)*a
(a < 0) -abs(x)*a
// basically any commutative operation
min(x,y) + max(x,y) = x + y
You can’t perform that action at this time.