Skip to content

Instantly share code, notes, and snippets.

@seewalker
seewalker / decomposed_error.py
Last active August 24, 2016 00:31
Decomposing Tensorflow Loss Function Into Foreground and Background pixels
# Assume Xgt is pixelwise, 1-of-k vector encoded ground truth.
# So, Xgt has dimensions (img_height,img_width,num_classes+1), such that the location of the '1' value in the third dimension indicates the true class.
# and that location being at "num_classes" indicates lack of available ground truth (i.e. a background pixel).
gtexists = tf.less(tf.argmax(Xgt,2),num_classes)
fg_gt = tf.boolean_mask(Xgt,gtexists)
bg_gt = tf.boolean_mask(Xgt,tf.logical_not(gtexists))
# fg_gt is of shape (?,num_classes+1) because the actual configuration of foreground/background pixels depends on the particular
# batch of input, so it is not known when constructing the computational graph here.
# Now, we can define separate error terms for errors where a foreground pixel is misclassified
@seewalker
seewalker / phasset2json.swift
Created January 4, 2016 05:46
Asynchronously Uploading Image from PHAsset as a Basic-Authenticated POST.
func phasset2json(asset:PHAsset) -> String {
let (username,password) = ("","")
let authData = "\(username):\(password)".dataUsingEncoding(NSUTF8StringEncoding)!
let encoded = authData.base64EncodedStringWithOptions(.Encoding76CharacterLineLength)
let basicAuthHeader = "Basic \(encoded)"
let urlPath: String = "https://server.com/blah?param=2"
let url: NSURL = NSURL(string: urlPath)!
var request: NSMutableURLRequest = NSMutableURLRequest(URL: url)
let boundary = NSString(format: "---------------------------14737809831466499882746641449")
request.HTTPMethod = "POST"
@seewalker
seewalker / gist:e0b836fc0faef7543ee4
Created July 3, 2014 22:10
Amber sff makefile (debugging the ambertools homebrew formula)
include ../config.h
.c.o:
$(CC) -c -Dflex $(COPTFLAGS) $(CFLAGS) $(AMBERCFLAGS) $(RISMSFF) $(NETCDFINC) -o $@ $<
OBJS = binpos.o conjgrad.o lmodC.o memutil.o nblist.o newton.o nmode.o \
prm.o rand2.o sasad.o sff.o time.o xminC.o AmberNetcdf.o atomic_number.o $(SFF_RISM_INTERFACE)
install: libsff hcp_getpdb