Skip to content

Instantly share code, notes, and snippets.

View svenkreiss's full-sized avatar

Sven Kreiss svenkreiss

View GitHub Profile
class GradScale100(torch.autograd.Function):
@staticmethod
def forward(ctx, input):
return input
@staticmethod
def backward(ctx, grad_output):
return grad_output * 0.01

Keybase proof

I hereby claim:

  • I am svenkreiss on github.
  • I am svenkreiss (https://keybase.io/svenkreiss) on keybase.
  • I have a public key ASByz07iHv4Qn2QKTFjTDgamfxLz09THQMl8hQ6ooeyTcAo

To claim this, I am signing this object:

class MapF(object):
def __init__(self, f):
self.f = f
def __call__(self, tc, i, x):
return (self.f(xx) for xx in x)
@svenkreiss
svenkreiss / word_count.py
Last active August 29, 2015 14:22
pysparkling example: word count
from pysparkling import Context
counts = Context().textFile(
'README.rst'
).flatMap(
lambda line: line.split(' ')
).map(
lambda word: (word, 1)
).reduceByKey(
lambda a, b: a + b