This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from numpy.random import uniform | |
def update(S, k, v): | |
"Update value position `k` in time O(log n)." | |
d = S.shape[0] | |
i = d//2 + k | |
S[i] = v | |
while i > 0: |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Cartoon version of Jiawei's optimization problem. | |
Created [2017-02-17 Fri] | |
""" | |
import numpy as np | |
from scipy.optimize import fmin_bfgs | |
import autograd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Simple example of manually performing "automatic" differentiation | |
""" | |
import numpy as np | |
from numpy import exp, sin, cos | |
def f(x, with_grad=False): | |
# Need to cache intermediates from forward pass (might not use all of them). | |
a = exp(x) |
OlderNewer