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 python | |
import numpy as np | |
def convert(image): | |
image = np.asarray(image) | |
if len(image.shape) == 2: | |
image = image[..., np.newaxis] | |
assert len(image.shape) == 3 | |
return image.transpose(2, 0, 1).copy() |
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 theano | |
import theano.tensor as T | |
pred, target = T.vectors('pt') # pred in (-inf, +inf), target in [0, 1] | |
L1 = T.nnet.binary_crossentropy(T.nnet.sigmoid(pred), target).sum() | |
L2 = T.nnet.sigmoid_binary_crossentropy(pred, target).sum() | |
fl1, fl2 = [theano.function([pred, target], L) for L in (L1, L2)] | |
g1, g2 = [theano.grad(L, [pred, target]) for L in (L1, L2)] |
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 theano | |
import theano.tensor as T | |
low = 'float32' | |
high = 'float64' | |
dtype_low, dtype_high = [T.TensorType(f, (False,)) for f in [low, high]] | |
pred32, target32 = dtype_low('p'), dtype_low('t') | |
pred64, target64 = dtype_high('p'), dtype_high('t') |
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
config defaultToCurrentScreen true | |
config nudgePercentOf screenSize | |
config resizePercentOf screenSize | |
# Resize Bindings | |
# bind right:alt resize +10% +0 | |
# bind left:alt resize -10% +0 | |
# bind up:alt resize +0 -10% | |
# bind down:alt resize +0 +10% | |
# bind right:ctrl;alt resize -10% +0 bottom-right |
This file has been truncated, but you can view the full file.
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
I1224 11:43:56.783612 2133 train_net.cpp:26] Starting Optimization | |
I1224 11:43:56.783983 2133 solver.cpp:26] Creating training net. | |
I1224 11:43:56.784008 2133 net.cpp:66] Creating Layer data | |
I1224 11:43:56.784013 2133 net.cpp:101] data -> data | |
I1224 11:43:56.784023 2133 net.cpp:101] data -> label | |
I1224 11:43:56.784036 2133 data_layer.cpp:122] Opening leveldb /home/jdonahue/caffe-train-leveldb | |
I1224 11:43:56.956717 2133 data_layer.cpp:159] output data size: 256,3,227,227 | |
I1224 11:43:56.956765 2133 data_layer.cpp:176] Loading mean file from/home/jiayq/ilsvrc2012_mean.binaryproto | |
I1224 11:43:57.016316 2133 net.cpp:116] Top shape: 3 227 227 | |
I1224 11:43:57.016341 2133 net.cpp:116] Top shape: 1 1 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/local/bin/python3 | |
import itertools | |
import string | |
class Node: | |
"""A trie node.""" | |
def __init__(self, char, parent=None): | |
self._char = char |
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 python | |
from __future__ import division | |
import functools | |
import itertools | |
import numpy as np | |
import os | |
import matplotlib.pyplot as plt | |
from PIL import Image |
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
try: | |
range = xrange # Python 2 | |
except NameError: | |
pass # Python 3 | |
def lazy_product(*iter_funcs, **kwargs): | |
""" | |
If f1, f2, ..., are functions which have no (required) arguments and | |
return iterables, then | |
lazy_product(f1, f2, ..., repeat=k) |
OlderNewer