Skip to content

Instantly share code, notes, and snippets.

Brandon T. Willard brandonwillard

Block or report user

Report or block brandonwillard

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
@brandonwillard
brandonwillard / pymc4-radon-optimization.org
Last active Oct 11, 2019
Symbolic PyMC Radon Model Optimization in PyMC4
View pymc4-radon-optimization.org

Symbolic PyMC: Radon Example in PyMC4

@brandonwillard
brandonwillard / profile_graph_goals.py
Last active Jul 28, 2019
Profiling miniKanren graph goals in `kanren`
View profile_graph_goals.py
import pstats
import cProfile
from unification import var
from kanren import run, eq
# Logical conjunction
from kanren import lall as lconj
@brandonwillard
brandonwillard / kanren-substitution-example.py
Created Jul 22, 2019
A Python example that uses miniKanren to substitute elements in a list/graph structure.
View kanren-substitution-example.py
from unification import var
from kanren import run, eq
# Logical conjunction
from kanren import lall as lconj
# Logical disjunction
from kanren import lany as ldisj
# `conde((a, b), (c, d), ...)` == `ldisj(lconj(a, b), lconj(c, d), ...)`
@brandonwillard
brandonwillard / tf-eager-mode-graph.py
Last active Jul 12, 2019
Getting a TensorFlow graph in eager-mode
View tf-eager-mode-graph.py
import tensorflow as tf
# from tensorflow.python.framework import ops
# ops.disable_eager_execution()
# Make sure we're in eager-mode
assert tf.executing_eagerly()
@tf.function
@brandonwillard
brandonwillard / investigate_tf_unify.py
Created Jun 1, 2019
Investigating unification for TensorFlow graphs/objects
View investigate_tf_unify.py
import tensorflow as tf
import tensorflow_probability as tfp
from tensorflow.python.framework import ops
ops.disable_eager_execution()
x_tf = tf.constant(1, name='x', dtype=tf.float64)
# An `Operation`
@brandonwillard
brandonwillard / graph-reduction-examples.scm
Last active Mar 26, 2019
Graph Manipulation Examples in microKanren
View graph-reduction-examples.scm
;; Using https://github.com/jasonhemann/microKanren
(load "microKanren.scm")
(load "miniKanren-wrappers.scm")
(define reduces
(lambda (a b)
(conde
((fresh (x)
(== a `(+ ,x ,x))
(== b `(* 2 ,x))))
@brandonwillard
brandonwillard / .pdbrc
Last active Mar 1, 2019
A `.pdbrc` that enables IPython's pretty printing in `[i]pdb`
View .pdbrc
#
# Make `pp` use IPython's pretty printer, instead of the standard `pprint` module.
#
# Sources: https://nedbatchelder.com/blog/200704/my_pdbrc.html
#
# XXX: This .pdbrc is only valid for Python >= 3.4
#
import pdb
import inspect as __inspect
from pprint import pprint as __pprint
@brandonwillard
brandonwillard / bayesian_hierarchical_re_centering.py
Last active Feb 20, 2019
Automatic Bayesian Hierarchical Model Re-centering/scaling in PyMC3
View bayesian_hierarchical_re_centering.py
"""
A demonstration of automatic parameter re-centering/scaling for the example
in https://twiecki.io/blog/2017/02/08/bayesian-hierchical-non-centered/
using https://github.com/pymc-devs/symbolic-pymc.
"""
import theano
import theano.tensor as tt
@brandonwillard
brandonwillard / org-babel-extensions.org
Last active Jan 24, 2019
Custom `org-babel` Extensions
View org-babel-extensions.org

Custom org-babel Extensions

Introduction

To get started, add a block like the following to an Org file that needs to reference the functions herein:

@brandonwillard
brandonwillard / Dockerfile
Created Aug 16, 2018
Dockerfile for Python 2.7 Tests of Hy
View Dockerfile
# -*- mode: Dockerfile -*-
#
# To build the image, in the Hy project root with this file present (and possibly renamed), run the following:
# docker build --rm -t hy-test-py27 -f Dockerfile .
#
# To launch a container, for the example image built above, and start an interactive session:
# docker run -ti --rm hy-test-py27:latest /bin/bash
#
# and to mount/expose a directory (`pwd` in this example) from the host at
# `/opt/hylang/hy` in the container:
You can’t perform that action at this time.