Skip to content

Instantly share code, notes, and snippets.

View zeakey's full-sized avatar

Kai Zhao zeakey

View GitHub Profile
class ExclusiveLinear(nn.Module):
def __init__(self, feat_dim=512, num_class=10572, norm_data=True, radius=20):
super(ExclusiveLinear, self).__init__()
self.num_class = num_class
self.feat_dim = feat_dim
self.norm_data = norm_data
self.radius = float(radius)
self.weight = nn.Parameter(torch.randn(self.num_class, self.feat_dim))
self.reset_parameters()
# multi-class cross-entropy loss with center-exclusive
from __future__ import print_function
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
from torch.autograd import Variable
from torch.optim import lr_scheduler
torch.backends.cudnn.bencmark = True
import os, sys, random, datetime, time
name: "ResNet-50"
input: "data"
input_dim: 1
input_dim: 3
input_dim: 224
input_dim: 224
layer {
bottom: "data"
top: "conv1"
### dual top-down path network for instance-level salient object detection
name: "LERG"
layer {
name: "data"
type: "Python"
top: "data"
top: "label"
python_param {
module: "pylayer"
layer: "ImageLabelMapDataLayer"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@zeakey
zeakey / debug_fsds.ipynb
Last active September 24, 2017 03:01
debug_fsds.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@zeakey
zeakey / install-caffe.sh
Created June 21, 2017 08:35
Script for caffe installation
#!/bin/bash
# install common deps
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y build-essential cmake make
sudo apt-get install --no-install-recommends libboost-all-dev
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
sudo apt-get install libatlas-base-dev
sudo apt-get install python-dev
@zeakey
zeakey / hed-caffe-netspec.py
Last active August 11, 2017 12:08
Python script for automatically generating HED(https://github.com/s9xie/hed) network, compatitable with newest caffe(https://github.com/bvlc/caffe)
import sys, os
sys.path.insert(0, 'path/to/caffe/python')
import caffe
from caffe import layers as L, params as P
from caffe.coord_map import crop
import numpy as np
def conv_relu(bottom, nout, ks=3, stride=1, pad=1, mult=[1,1,2,0]):
conv = L.Convolution(bottom, kernel_size=ks, stride=stride,
num_output=nout, pad=pad, weight_filler=dict(type='xavier'),