Skip to content

Instantly share code, notes, and snippets.

[{"place_id":"97994878","licence":"Data \u00a9 OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","osm_type":"relation","osm_id":"161950","boundingbox":["30.1375217437744","35.0080299377441","-88.4731369018555","-84.8882446289062"],"lat":"33.2588817","lon":"-86.8295337","display_name":"Alabama, United States of America","place_rank":"8","category":"boundary","type":"administrative","importance":0.83507032450272,"icon":"http:\/\/nominatim.openstreetmap.org\/images\/mapicons\/poi_boundary_administrative.p.20.png"}]
[{"place_id":"97421560","licence":"Data \u00a9 OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","osm_type":"relation","osm_id":"162018","boundingbox":["31.3321762084961","37.0042610168457","-114.818359375","-109.045196533203"],"lat":"34.395342","lon":"-111.7632755","display_name":"Arizona, United States of America","place_rank":"8","category":"boundary","type":"administrative","importance":0.83922181098242,"icon":"http:\/\/nominatim.openst
{
"Mississippi": [30.1477890014648, 34.9960556030273, -91.6550140380859, -88.0980072021484],
"Oklahoma": [33.6191940307617, 37.0021362304688, -103.002571105957, -94.4312133789062],
"Delaware": [38.4511260986328, 39.8394355773926, -75.7890472412109, -74.9846343994141],
"Minnesota": [43.4994277954102, 49.3844909667969, -97.2392654418945, -89.4833831787109],
"Illinois": [36.9701309204102, 42.5083045959473, -91.513053894043, -87.0199203491211],
"Arkansas": [33.0041046142578, 36.4996032714844, -94.6178131103516, -89.6422424316406],
"New Mexico": [31.3323001861572, 37.0001411437988, -109.050178527832, -103.000862121582],
"Indiana": [37.7717399597168, 41.7613716125488, -88.0997085571289, -84.7845764160156],
"Louisiana": [28.9210300445557, 33.019458770752, -94.0431518554688, -88.817008972168],
@jiqiujia
jiqiujia / min-char-rnn.py
Created July 29, 2016 06:34 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@jiqiujia
jiqiujia / pg-pong.py
Created September 22, 2016 06:11 — forked from karpathy/pg-pong.py
Training a Neural Network ATARI Pong agent with Policy Gradients from raw pixels
""" Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym. """
import numpy as np
import cPickle as pickle
import gym
# hyperparameters
H = 200 # number of hidden layer neurons
batch_size = 10 # every how many episodes to do a param update?
learning_rate = 1e-4
gamma = 0.99 # discount factor for reward
@jiqiujia
jiqiujia / genSpectrogram.m
Created October 16, 2016 13:41
generate the spectrogram of one dimensional signal
%%reference: http://www.mathworks.com/help/signal/ref/spectrogram.html
dat = load('/media/dl/data1/kaggle_eeg_2016/train_1/1_1_1.mat');
dat = dat.dataStruct.data;
dat = dat(:, 1);
Nx = length(dat); %sample number
nsc = floor(Nx/600); %number of signal sections
nov = floor(nsc/2); %overlap between adajacent windows
nff = max(256,2^nextpow2(nsc)); %number of samples to compute the FFT
@jiqiujia
jiqiujia / lasagne_util.py
Created October 16, 2016 13:44
util function using lasagne
def architecture_string(layer):
model_arch = ''
for i, layer in enumerate(lasagne.layers.get_all_layers(layer)):
name = string.ljust(layer.__class__.__name__, 28)
model_arch += " %2i %s %s " % (i, name,
lasagne.layers.get_output_shape(layer))
if hasattr(layer, 'filter_size'):
model_arch += str(layer.filter_size[0])
@jiqiujia
jiqiujia / learn.lua
Created November 7, 2016 14:03 — forked from tylerneylon/learn.lua
Learn Lua quickly with this short yet comprehensive and friendly script. It's written as both an introduction and a quick reference. It's also a valid Lua script so you can verify that the code does what it says, and learn more by modifying and running this script in your Lua interpreter.
-- Two dashes start a one-line comment.
--[[
Adding two ['s and ]'s makes it a
multi-line comment.
--]]
----------------------------------------------------
-- 1. Variables and flow control.
----------------------------------------------------
@jiqiujia
jiqiujia / magnet_loss_utils.py
Created November 21, 2016 11:28
util functions of paper 'metric learning with adaptive density discrimination'
from math import ceil
import numpy as np
from sklearn.cluster import KMeans
import theano
import theano.tensor as T
def compute_reps(extract_fn, X, chunk_size):
"""Compute representations for input in chunks."""
chunks = int(ceil(float(X.shape[0]) / chunk_size))
"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 (cameron.craddock@gmail.com)
#
# 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