Skip to content

Instantly share code, notes, and snippets.

@jiqiujia
jiqiujia / tmux.conf
Last active March 14, 2017 08:04
tmux2.3 configuration file
#设置前缀为Ctrl + a
unbind ^b
set -g prefix 'C-a'
#将r 设置为加载配置文件,并显示信息
bind r source-file ~/.tmux.conf \; display-message "Config reloaded"
#up
bind-key k select-pane -U
#down
bind-key j select-pane -D
"Pathogen
execute pathogen#infect()
syntax on
filetype plugin indent on
"NERDtree
" open NERDTree with ctrl+n
map <F2> :NERDTreeToggle<CR>
" close vim if the only window left open is a NERDTree
autocmd bufenter * if(winnr("$")==1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
@jiqiujia
jiqiujia / ncut.py
Last active December 24, 2016 08:39
graph util functions in python, from https://github.com/mdeff/ntds_2016
# ### python_ncut_lib.py
# Copyright (C) 2010 R. Cameron Craddock ([email protected])
#
# This script is a part of the pyClusterROI python toolbox for the spatially constrained clustering of fMRI
# data. It provides the library functions for performing normalized cut clustering according to:
#
# Shi, J., & Malik, J. (2000). Normalized cuts and image segmentation. IEEE Transactions on Pattern Analysis
# and Machine Intelligence, 22(8), 888-905. doi: 10.1109/34.868688.
#
# Yu, S. X., & Shi, J. (2003). Multiclass spectral clustering. Proceedings Ninth IEEE International Conference
@jiqiujia
jiqiujia / utils.py
Last active April 1, 2017 09:15
keras
#adjust learning rate policy by callbacks
def scheduler(epoch):
if epoch == 5:
model.lr.set_value(.02)
return model.lr.get_value()
change_lr = LearningRateScheduler(scheduler)
model.fit(x_embed, y, nb_epoch=1, batch_size = batch_size, show_accuracy=True,
callbacks=[chage_lr])
@jiqiujia
jiqiujia / dcgan.py
Created January 30, 2017 13:43 — forked from soumith/dcgan.py
import torch
import torch.nn as nn
import torch.nn.parallel
class DCGAN_D(nn.Container):
def __init__(self, isize, nz, nc, ndf, ngpu, n_extra_layers=0):
super(DCGAN_D, self).__init__()
self.ngpu = ngpu
assert isize % 16 == 0, "isize has to be a multiple of 16"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jiqiujia
jiqiujia / elastic_transform.py
Created May 24, 2017 03:06 — forked from chsasank/elastic_transform.py
Elastic transformation of an image in Python
import numpy as np
from scipy.ndimage.interpolation import map_coordinates
from scipy.ndimage.filters import gaussian_filter
def elastic_transform(image, alpha, sigma, random_state=None):
"""Elastic deformation of images as described in [Simard2003]_.
.. [Simard2003] Simard, Steinkraus and Platt, "Best Practices for
Convolutional Neural Networks applied to Visual Document Analysis", in
@jiqiujia
jiqiujia / plot.py
Last active July 24, 2017 13:15
python plot util
#plot tiled images
fig = plt.figure(figsize=(8,8))
#adjust the white space around the figure and each subplot
plt.subplots_adjust(wspace=0.01, hspace=0.01, left=0, right=1, bottom=0, top=1)
for i in range(63):
ax = plt.subplot(8,8,i+1)
plt.imshow(imgs[i])
ax.axis('off') #no frame
#ax.get_xaxis().set_visible(False)
#ax.get_yaxis().set_visible(False)
@jiqiujia
jiqiujia / shape_index.py
Created November 2, 2017 12:11 — forked from davecg/shape_index.py
Calculate 3D shape index using PyTorch
import numpy as np
import matplotlib.pyplot as plt
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
from torch.autograd import Variable
import torchvision
import torchvision.transforms as transforms
import numpy as np
@jiqiujia
jiqiujia / hessians.py
Created November 3, 2017 01:38
tensorflow utils
### Adapted from TF repo
import tensorflow as tf
from tensorflow import gradients
from tensorflow.python.framework import ops
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import math_ops
def hessian_vector_product(ys, xs, v):