This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{"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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BatchNormLayer(lasagne.layers.Layer): | |
def __init__(self, incoming, b=lasagne.init.Constant(0.), g=lasagne.init.Constant(1.), | |
W=lasagne.init.Normal(0.05), nonlinearity=relu, **kwargs): | |
super(BatchNormLayer, self).__init__(incoming, **kwargs) | |
self.nonlinearity = nonlinearity | |
k = self.input_shape[1] | |
if b is not None: | |
self.b = self.add_param(b, (k,), name="b", regularizable=False) | |
if g is not None: | |
self.g = self.add_param(g, (k,), name="g") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_conf_matrix(expected, predicted, n_classes): | |
m = np.zeros((n_classes, n_classes)) | |
for pred, exp in zip(predicted, expected): | |
m[pred][exp] += 1 | |
return m | |
def calc_accuracy(conf_matrix): | |
t = sum(sum(l) for l in conf_matrix) | |
return sum(conf_matrix[i][i] for i in range(len(conf_matrix))) / t |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Two dashes start a one-line comment. | |
--[[ | |
Adding two ['s and ]'s makes it a | |
multi-line comment. | |
--]] | |
---------------------------------------------------- | |
-- 1. Variables and flow control. | |
---------------------------------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
OlderNewer