Skip to content

Instantly share code, notes, and snippets.

taey16

Block or report user

Report or block taey16

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
@taey16
taey16 / gen_seq.py
Last active Oct 11, 2016
min_char_rnn
View gen_seq.py
import numpy as np
import sys
import scipy.io as sio
def sample(hprev, xt, n):
for index in xt:
x = np.zeros((vocab_size, 1))
x[index] = 1
h = np.tanh(np.dot(Wxh, x) + np.dot(Whh, hprev) + bh)
y = np.dot(Why, h) + by
@taey16
taey16 / predict_ilsvrc12_ResNet.py
Last active Jul 4, 2018
predict_ilsvrc12_ResNet.py
View predict_ilsvrc12_ResNet.py
import numpy as np
import sys
import caffe
from caffe import caffe_utils as utils
import datetime
CAFFE_ROOT='/works/caffe/'
MODEL_DEPLOY_FILE = \
#'/storage/ImageNet/ILSVRC2012/model/resnet/ResNet_caffe_models/ResNet-50-deploy.prototxt'
@taey16
taey16 / lr_per_layer.lua
Created Oct 25, 2015
Assign different learning rate for a layer
View lr_per_layer.lua
-- suppose you have a model called model
lrs_model = model:clone()
lrs = lrs_model:getParameters()
lrs:fill(1) -- setting the base learning rate to 1
-- now lets set the learning rate factor of the bias of module 5 to 2
lrs_model:get(5).bias:fill(2)
-- same thing for the weights of module 2, let's set them to 3
lrs_model:get(2).weight:fill(3)
View convertLiner2Conv.lua
require 'nn'
-- you just need to provide the linear module you want to convert,
-- and the dimensions of the field of view of the linear layer
function convertLinear2Conv1x1(linmodule,in_size)
local s_in = linmodule.weight:size(2)/(in_size[1]*in_size[2])
local s_out = linmodule.weight:size(1)
local convmodule = nn.SpatialConvolutionMM(s_in,s_out,in_size[1],in_size[2],1,1)
convmodule.weight:copy(linmodule.weight)
convmodule.bias:copy(linmodule.bias)
View test_numpy_multithreading.py
#!/usr/bin/env python
import numpy
import sys
import timeit
try:
import numpy.core._dotblas
print 'FAST BLAS'
except ImportError:
print 'slow blas'
@taey16
taey16 / convert_vgg.lua
Last active Aug 18, 2016
convert_caffe
View convert_vgg.lua
require 'loadcaffe'
require 'nn'
local model_root = '/storage/models/vgg'
local deploy_file = paths.concat(model_root, 'vgg_layer16_deploy.prototxt')
local weight_file = paths.concat(model_root, 'vgg_layer16.caffemodel')
local model = loadcaffe.load(deploy_file, weight_file, nn)
return model
You can’t perform that action at this time.