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
$ lein with-profile main-sentclass run --model-type bilstm --num-data 8000 --embed-file data/glove.6B.300d.txt --emb-size 300 | |
Reflection warning, /private/var/folders/cg/mm4fc_4j3_96tm1fpqkm4v5w0000gn/T/form-init2811519414259970652.clj:1:1201 - call to static method invokeStaticMethod on clojure.lang.Reflector can't be resolved (argument types: unknown, java.lang.String, unknown). | |
WARNING: any? already refers to: #'clojure.core/any? in namespace: vertigo.core, being replaced by: #'vertigo.core/any? | |
{:train-file data/sentiment-train10k.txt, :test-file data/sentiment-test10k.txt, :embed-file data/glove.6B.300d.txt, :num-classes 2, :emb-size 300, :model-type :bilstm, :lstm-size 25, :num-data 8000} | |
Params ([lstm/input->gates/b [200]] [hidden->logits/W [2 50]] [lstm/input->gates/W [200 650]] [hidden->logits/b [2]]) | |
Total # params 130302 | |
Optimizing with flare.optimize.Adadelta | |
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". | |
SLF4J: Defaulting to no-operation (NOP) logger implementation | |
SLF4J: See |
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 sys | |
# HACK: keras prints to stdout which messes with halite | |
stdout = sys.stdout | |
stderr = sys.stderr | |
sys.stdout = open('/dev/null', 'w') | |
sys.stderr = open('/dev/null', 'w') | |
from keras import models | |
from keras.callbacks import ModelCheckpoint |
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 csv | |
import heapq | |
from random import randint | |
# no heapq implementation | |
def up_heapify(length, P, L, i): | |
idx, ix = L[i] | |
while i: | |
pi = (i-1) >> 1 #(i-1)/2 | |
pidx, pix = L[pi] |
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 heapq | |
import csv | |
# no heapq implementation | |
def up_heapify(L, i): | |
while i: | |
pi = (i-1)/2 | |
if L[pi] > L[i]: | |
L[i], L[pi] = L[pi], L[i] | |
i = pi |
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 match(player1, player2): | |
moves1 = [] | |
moves2 = [] | |
wins1 = 0 | |
wins2 = 0 | |
for i in xrange(1000): | |
move1 = player1(moves1, moves2) | |
move2 = player2(moves2, moves1) | |
#print move1, move2 | |
moves1.append(move1) |
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
## Credits: | |
## | |
## Collaborative effort: | |
## - Michel Dusseault wrote the code. | |
## - I worked out some of the differential equations. | |
## | |
var('t') | |
g = 9.81 # m/s^2 | |
rho = 1.2 # Rho: Density of air at sea level @ 25C |
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
file_list = ["10.1.1.111.1781.pdf", "10.1.1.111.5264.pdf", "10.1.1.39.1596.pdf", "10.1.1.41.8589.pdf", "10.1.1.42.5619.pdf"] | |
apps = [ | |
"/Applications/Adobe Reader 9/Adobe Reader.app/Contents/MacOS/AdobeReader", | |
"/Applications/Adobe Reader.app/Contents/MacOS/AdobeReader", | |
"/Applications/Preview.app/Contents/MacOS/Preview"] | |
fuzz_output = "fuzz.pdf" | |
FuzzFactor = 250 |
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
# | |
# Write centrality_max to return the maximum distance | |
# from a node to all the other nodes it can reach | |
# | |
from collections import deque | |
def centrality_max(G, v): | |
open_list = deque([v]) | |
distance = {v: 0} |
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
## Tests | |
import time, random | |
def from_file(filename, sep='\n'): | |
"Parse a file into a list of strings, separated by sep." | |
return file(filename).read().strip().split(sep) | |
def parse_grid(gridstr): | |
gridstr = gridstr.replace('\n', '') | |
return [[int(gridstr[i+9*j]) for i in range(9)] for j in range(9)] |
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 times(A, B): | |
return [(i,j) for i in A for j in B] | |
dims = range(9) | |
subdims = ([0,1,2],[3,4,5],[6,7,8]) | |
squares = times(dims, dims) | |
unitlist = ([times(dims, [c]) for c in dims] + | |
[times([r], dims) for r in dims] + | |
[times(rs, cs) for rs in subdims for cs in subdims]) | |
units = dict((s, [u for u in unitlist if s in u]) |
NewerOlder