Skip to content

Instantly share code, notes, and snippets.

Jeff Donahue jeffdonahue

Block or report user

Report or block jeffdonahue

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jeffdonahue
jeffdonahue / .slate
Created Jul 17, 2017 — forked from teruhisa/.slate
slate sizeup settings
View .slate
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
View test_sbce_stable.py
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')
View test_sbce.py
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)]
View gifify_image.py
#!/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()
View solver.prototxt
net: "train_val.prototxt"
test_iter: 736
test_interval: 1000000 # py solving tests
display: 1
average_loss: 100
# lr_policy: "fixed"
lr_policy: "step"
stepsize: 50000
gamma: 0.1
# base_lr: 1e-4
View train_scratch_ms.sh
#!/bin/bash
set -x
set -e
export LD_LIBRARY_PATH='/usr/local/cuda/lib64/'
export PYTHONUNBUFFERED="True"
NAME="scratch"
NAME="/tmp/magic_caffenet.caffenet"
if [ "$#" -ge 1 ]; then
NAME=${2}
View eval_model.sh
#!/usr/bin/env bash
set -e
set -x
GPU=0
CWD=$(pwd)
CAFFE_DIR=/raid/jdonahue/philkr-caffe
MAGIC_DIR=~/magic_init
CLASS_DIR=/raid/jdonahue/voc-classification
View stable_mean.py
import numpy as np
def canonical_axis(x, axis):
def is_int_ndarray(x):
if not isinstance(x, np.ndarray):
return False
dtype = str(x.dtype)
prefixes = 'int', 'uint'
return any(dtype.startswith(p) for p in prefixes)
if axis is None:
@jeffdonahue
jeffdonahue / resize_imageset.py
Last active May 16, 2016
resize a directory of images
View resize_imageset.py
#!/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
View count_caffemodel_params.py
#!/usr/bin/env python
# usage: python count_caffemodel_params.py /path/to/my.caffemodel [/path/to/my/other.caffemodel, ...]
from caffe.proto import caffe_pb2
import sys
assert len(sys.argv) >= 2
for caffemodel_filename in sys.argv[1:]:
You can’t perform that action at this time.