Skip to content

Instantly share code, notes, and snippets.

View blooberr's full-sized avatar

Jon Hsieh blooberr

View GitHub Profile
@blooberr
blooberr / guided_relu.py
Created December 11, 2016 10:00 — forked from falcondai/guided_relu.py
Tensorflow implementation of guided backpropagation through ReLU
import tensorflow as tf
from tensorflow.python.framework import ops
from tensorflow.python.ops import gen_nn_ops
@ops.RegisterGradient("GuidedRelu")
def _GuidedReluGrad(op, grad):
return tf.select(0. < grad, gen_nn_ops._relu_grad(grad, op.outputs[0]), tf.zeros(grad.get_shape()))
if __name__ == '__main__':
with tf.Session() as sess:
from keras.models import Sequential
from keras.layers.core import Dense, Dropout, Activation, Flatten
from keras.layers.convolutional import Convolution2D, MaxPooling2D
from keras.layers.normalization import BatchNormalization
#AlexNet with batch normalization in Keras
#input image is 224x224
model = Sequential()
model.add(Convolution2D(64, 3, 11, 11, border_mode='full'))
@blooberr
blooberr / ruby dup
Last active October 18, 2016 03:47
a = [5, 3, 2]
b = a
# should see [5,3,2]
puts b.inspect
a[0] = 7
# should see [7,3,2]
puts b.inspect
@blooberr
blooberr / cv_utils.cpp
Created June 8, 2016 17:12 — forked from tanmaykm/cv_utils.cpp
Separating items in store shelves using OpenCV.
/*
* cv_utils.cpp
*
* Created on: Dec 7, 2012
* Author: tan
* Related blog post at:
* http://sidekick.windforwings.com/2012/12/opencv-separating-items-on-store-shelves.html
*
*/
class Card
def initialize
end
def rank
@rank
end
def rank=(r)
# you can do other stuff in here
class Card
def initialize
self.rank
end
def rank
puts "hello"
end
end
@blooberr
blooberr / nginx.conf
Last active August 29, 2015 14:17 — forked from Stanback/nginx.conf
#
# CORS header support
#
# One way to use this is by placing it into a file called "cors_support"
# under your Nginx configuration directory and placing the following
# statement inside your location block(s):
#
# include cors_support;
#
# A limitation to this method is that Nginx doesn't currently send headers
@blooberr
blooberr / sse.go
Last active August 29, 2015 14:06 — forked from ismasan/sse.go
package main
import (
"fmt"
"log"
"net/http"
"time"
)
// Example SSE server in Golang.
myhost = "localhost"
@es = Elasticsearch::Client.new host: myhost, port: 9200, log: true
@es.create index: "hello",
type: "world",
id: "someitem",
body: {
text: "yup",
count: 1
results = @es.search(index: index_name,
ignore_unavailable: true,
body: {
size: 0,
query: {
query_string: {
query: search_phrase
}
}
})