Skip to content

Instantly share code, notes, and snippets.

@timvieira
timvieira / make-wrapper.bash
Created November 19, 2016 19:38
Make wrapper - Guesses what I meant when there was no Makefile in the current directory.
function yellow { echo -e "\e[33m$@\e[0m"; }
# Wrapper around make, which covers building different project types, when an
# actual Makefile isn't present.
function make {
if [[ -e Makefile ]]; then
yellow "[make] found Makefile"
/usr/bin/make $@
else
yellow "[make] No Makefile found"
import numpy as np
import pylab as pl
from numpy import exp, cos, sin, sqrt
from arsenal.math import compare
def run_tests():
tests = """
x**2
2*x
@timvieira
timvieira / jiawei.py
Created February 18, 2017 20:18
Cartoon version of Jiawei's optimization problem.
"""
Cartoon version of Jiawei's optimization problem.
Created [2017-02-17 Fri]
"""
import numpy as np
from scipy.optimize import fmin_bfgs
import autograd
@timvieira
timvieira / memory-efficient-backprop.py
Created August 8, 2017 17:41
Memory efficient backpropagation thru time in a recurrent neural network. Accompanies blog post: http://timvieira.github.io/blog/post/2016/10/01/reversing-a-sequence-with-sublinear-space/
"""
Memory-efficient backpropagation in an RNN.
Accompanies blog post:
http://timvieira.github.io/blog/post/2016/10/01/reversing-a-sequence-with-sublinear-space/
"""
import numpy as np
from arsenal.math.checkgrad import fdcheck
# Efficient passive aggressive updates for multi-class classification
#
# Original article:
# "Column squishing for multiclass updates"
# https://nlpers.blogspot.com/2017/08/column-squishing-for-multiclass-updates.html
from __future__ import division
import numpy as np
import scipy.optimize
"""
Memory-efficient backpropagation in an RNN.
Accompanies blog post:
http://timvieira.github.io/blog/post/2016/10/01/reversing-a-sequence-with-sublinear-space/
"""
import numpy as np
from arsenal.math.checkgrad import fdcheck
@timvieira
timvieira / reverse.py
Last active January 16, 2018 17:26
Reversing a singly-linked sequence defined by a function application with sublinear space.
# -*- coding: utf-8 -*-
"""
Reversing a singly-linked sequence defined by a function application in
sublinear space.
s[t] = f(s[t-1]) where s[0] is given as input.
Code associated with blog post
"Reversing a sequence with sublinear space"
http://timvieira.github.io/blog/post/2016/10/01/reversing-a-sequence-with-sublinear-space/
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@timvieira
timvieira / lagrangeprop.py
Last active May 1, 2022 06:54
Automatic differentiation as the method of Lagrange multipliers. Code accompanies this blog post: http://timvieira.github.io/blog/post/2017/08/18/backprop-is-not-just-the-chain-rule/
# -*- coding: utf-8 -*-
"""
Backprop as the method of Lagrange multiplers (and even the implicit function
theorem).
"""
from __future__ import division
import numpy as np
from arsenal.alphabet import Alphabet
from arsenal.math.checkgrad import finite_difference
@timvieira
timvieira / counterfactual-demo.ipynb
Last active May 12, 2022 05:25
Counterfactual reasoning demo. Accompanies blog post "Counterfactual reasoning and learning from logged data" http://timvieira.github.io/blog/post/2016/12/19/counterfactual-reasoning-and-learning-from-logged-data/
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.