Skip to content

Instantly share code, notes, and snippets.

@jakeoung
jakeoung / effect_normalization_in_LoG.jl
Last active January 19, 2020 16:50
Effect of normalization in Laplacian of Gaussian
using Plots
using SpecialFunctions
function GoS(x)
-(1 .- erf.(x))
end
function G(x, sigma)
exp.(-x.^2 ./ (2*sigma^2))
end
@jakeoung
jakeoung / gist:92e7666f6ada918b72eccd3b6275b21a
Created November 25, 2019 19:20
Get a forward operator as a sparse matrix in astra toolbox
import numpy as np
import matplotlib.pyplot as plt
import astra
if 0:
data_corr = np.load('tomo_corr.npy')
vecs = np.load('vectors.npy')
else:
import scipy.io
data_mat = scipy.io.loadmat('../data/Fewer_Plastics_tomo_corr_low_high_vectors')
@jakeoung
jakeoung / install_basic_tools.sh
Created November 4, 2017 15:39
install basic tools in docker
apt-get upgrade
apt-get install python-setuptools git vim
easy_install pip
@jakeoung
jakeoung / make_boot_script.sh
Created November 4, 2017 14:46
make starting script
sudo echo "su ubuntu -c 'bash /home/ubuntu/start_script.sh'" >> /etc/rc.local
# make ~/start_script.sh
echo "LABEL=cloudimg-rootfs / ext4 defaults 0 0
/dev/xvdb /home01 ext4 defaults 0 2" >> /etc/fstab
@jakeoung
jakeoung / install_tmux-resurrect.sh
Last active November 4, 2017 13:00
install tmux save
## STEP1: install tmux-plugin
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
echo "# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin 'git@github.com/user/plugin'
@jakeoung
jakeoung / cb_customs.py
Last active May 10, 2017 02:26
convert bibliography for ai
import re
import requests
import titlecase
# I doubt if we need to go above ten
words_to_numerals =\
{
'first': '1',
'second': '2',
'third': '3',
@jakeoung
jakeoung / jkimg.c
Last active June 3, 2017 14:23
jkimg.c, jkimg.h, jkimg.cuh
/*
JKImage library for communicating with python
Rules
- The input image usually follows the order of [Channel x ny x nx]
-
*/
#include <math.h>
#include <stdio.h>
@jakeoung
jakeoung / example_argparse.py
Last active June 5, 2017 07:26
jkplot library and python argparse usage of making file name and loading
########## main.py
import argparse
import time
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument('--niter', type=int, default=100, help='number of iteration')
args, unparsed = parser.parse_known_args()
# make output file name containing the key parameters
@jakeoung
jakeoung / F.log_softmax(x).py
Last active February 11, 2017 12:20
Implementing pytorch functions
import torch.autograd.Variable
max, max_idx = Variable.max(x, 1)
max = Variable.expand_as(max, x)
x = Variable.exp(x - max)
p = Variable(torch.zeros(x.size()))
for i in range(64):
sum = Variable.sum(x[i, :]).data[0]
p[i, :] = x[i, :] / sum