Skip to content

Instantly share code, notes, and snippets.

Probably drinking coffee

George Ho eigenfoo

Probably drinking coffee
View GitHub Profile
def linear_regression(x):
scale = yield tfd.HalfCauchy(0, 1)
coefs = yield tfd.Normal(tf.zeros(x.shape[1]), 1, )
predictions = yield tfd.Normal(tf.linalg.matvec(x, coefs), scale)
return predictions
def linear_regression(x):
scale = tfd.HalfCauchy(0, 1)
coefs = tfd.Normal(tf.zeros(x.shape[1]), 1)
predictions = tfd.Normal(tf.linalg.matvec(x, coefs), scale)
return predictions
linear_regression.model_generator(tf.zeros([3, 10])) # Shape is irrelevant here
class Model:
""" pm.Model decorator. """
def __init__(self, func):
self.func = func
# Introspect wrapped function, instead of the decorator class.
functools.update_wrapper(self, func)
# Uncompile wrapped function.
class FunctionToGenerator(ast.NodeTransformer):
This subclass traverses the AST of the user-written, decorated,
model specification and transforms it into a generator for the
model. Subclassing in this way is the idiomatic way to transform
an AST.
1. Add `yield` keywords to all assignments
eigenfoo /
Created Dec 15, 2019
PyMC3 `pymc3/step_methods/hmc/` as of dc9fd725
from collections import namedtuple
import theano
import theano.tensor as tt
import numpy as np
from pymc3.theanof import join_nonshared_inputs, gradient, CallableTensor, floatX
Hamiltonian = namedtuple("Hamiltonian", "logp, dlogp, pot")
eigenfoo /
Created Sep 9, 2019
Template file
""" Template file """
from os.path import dirname, realpath, join, exists
from re import search, M
from setuptools import setup, find_packages
# TODO: add package details
NAME = ""
eigenfoo /
Created Jun 24, 2019
Print a Markdown table of contents for a Jupyter notebook.
import argparse
import re
import json
import string
parser = argparse.ArgumentParser(
description="Print a Markdown table of contents for a Jupyter notebook."
eigenfoo / blog.png
Last active Jun 17, 2019
Personal website and blog
eigenfoo / NeutralPolitics.csv
Created Apr 18, 2019
Dump of r/NeutralPolitics comments.
View NeutralPolitics.csv
We can't make this file beautiful and searchable because it's too large.

Keybase proof

I hereby claim:

  • I am eigenfoo on github.
  • I am eigenfoo ( on keybase.
  • I have a public key ASCsD4wjzqoNalT86VzogMM7vxt5G8z1qv6uFtYRWd9aOQo

To claim this, I am signing this object: