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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import torch.nn as nn | |
import torch | |
import torchvision.datasets as datasets | |
import torchvision.transforms as transforms | |
from torch.autograd import Variable, grad | |
import torch.optim as optim | |
import torchvision.utils as vutils |
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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
# implementation of backpropogation algorithm based on | |
# http://neuralnetworksanddeeplearning.com/chap1.html | |
# | |
# note that mini-batches are calculated in matrix form | |
import numpy as np | |
import random |
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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
from sklearn.datasets import load_iris | |
import numpy as np | |
import math | |
import matplotlib.pyplot as plt | |
from mpl_toolkits.mplot3d import Axes3D | |
from scipy.optimize import fmin_bfgs |
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 matplotlib.pyplot as plt | |
from mpl_toolkits.mplot3d import Axes3D | |
import math | |
#============================================================================== | |
# Try to verify the cost function is non-convex | |
xs = np.random.rand(30) | |
ys = np.random.rand(30) |
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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import math | |
class DecisionTree(object): | |
def __init__(self, data, method="naive"): | |
"""Learn a decision tree from data and label | |
:data: List[List[val]], a list contains M sample, each sample is represented by a List | |
The last column of the sample is the label |
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
def generate(c1,c2,bitlen): | |
a = c1 & ~(1<<bitlen) | |
b = c2 & ~(1<<bitlen) | |
c = c1 >> 1 | |
d = c2 >> 1 | |
return (a&~b&~c&~d) | (~a&b&~c&~d) | (~a&~b&c&~d) | (~a&~b&~c&d) | |
from collections import defaultdict | |
def build_map(n, nums): | |
mapping = defaultdict(set) |
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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import subprocess | |
import re | |
import json | |
import sys | |
from math import ceil | |
TMUX_BUFFER_NAME = 'dwm' |
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
; Sieve of Eratosthenes | |
; Checkout https://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf | |
(def primes | |
(concat | |
[2] | |
(lazy-seq | |
(let [prime-inner | |
(fn prime-inner [x table] | |
(if (table x) | |
(prime-inner (inc 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
set autoupdategist | |
set smoothscroll | |
let scrollstep = 90 | |
let scrollduration = 30 | |
let barposition = "bottom" | |
" vimperator style follow link | |
let numerichints = 1 | |
let typelinkhints = 1 |
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
#!/usr/bin/env python2 | |
# -*- coding: utf-8 -*- | |
from PIL import Image | |
def chunks(l, n): | |
"""Yield successive n-sized chunks from l.""" | |
for i in range(0, len(l), n): | |
yield l[i:i + n] |