Skip to content

Instantly share code, notes, and snippets.

View chrischoy's full-sized avatar

Chris Choy chrischoy

View GitHub Profile
@chrischoy
chrischoy / smoothed_triplet_loss.py
Last active March 13, 2021 11:50
Smoothed triplet loss from Deep Metric Learning via Lifted Structured Feature Embedding, CVPR 2016
import tensorflow as tf
import numpy as np
def smoothed_metric_loss(input_tensor, name='smoothed_triplet_loss', margin=1):
'''
input_tensor: require a tensor with predefined dimensions (No None dimension)
Every two consecutive vectors must be a positive pair. There
should not be more than one pair from each class.
'''
with tf.variable_scope(name):
@chrischoy
chrischoy / activate
Last active April 4, 2017 23:10
Activate
#!/bin/sh
SERVER=$1
ENVNAME=$2
ENV_ROOT="/cvgl/u/chrischoy/.pyv/${SERVER}/${ENVNAME}/bin"
# Check the number of arguments
if [ "$#" -eq 2 ] && [ -d "${ENV_ROOT}" ]; then
export OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
# Personalized theme based on kafeitu
# Grab the current date (%D) and time (%T) wrapped in {}: {%D %T}
CURRENT_TIME_="%{$fg_bold[white]%}{%{$fg_bold[yellow]%}%D %T%{$fg_bold[white]%}}%{$reset_color%}"
PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%n%{$fg[cyan]%}@%{$fg_bold[green]%}%m%{$fg_bold[green]%}%p %{$fg[cyan]%}%~ %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%}% %{$reset_color%}'
RPROMPT='$CURRENT_TIME_'
ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
@chrischoy
chrischoy / cuda_compile.m
Created March 3, 2015 19:08
CUDA + Mex compile
function cuda_compile( src_path, func_name, matlab_root, cuda_root, out_path, debug)
%CUDA_COMPILE general cuda compiling helper for MATLAB version < 2014a
if nargin < 6
debug = false;
end
if ~exist('./bin', 'dir')
mkdir('./bin')
end