This file contains 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
import keras.backend as K | |
from keras.layers import Dense, Activation, Multiply, Add, Lambda | |
import keras.initializers | |
def highway_layers(value, n_layers, activation="tanh", gate_bias=-3): | |
dim = K.int_shape(value)[-1] | |
gate_bias_initializer = keras.initializers.Constant(gate_bias) | |
for i in range(n_layers): | |
gate = Dense(units=dim, bias_initializer=gate_bias_initializer)(value) | |
gate = Activation("sigmoid")(gate) |
This file contains 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
import time | |
import numpy as np | |
import sklearn.decomposition | |
import seaborn | |
RANK = 50 | |
N_COLS = 1000 | |
def evaluate_svd(svd_fn, reconstruct_fn, min_rows=100, max_rows=5000, n_samples=100, n_cols=N_COLS, rank=RANK, random_seed=0): | |
np.random.seed(random_seed) |
This file contains 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
object ForLoop { | |
def main(args: Array[String]) { | |
var acc = 0L | |
for (i <- 0L to 1000000000L) { | |
acc += i | |
} | |
println("For loop!") | |
} | |
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
import numpy as np | |
LeftCounts = np.array([150,150]) | |
RightCounts = np.array([200,200]) | |
NLeft = sum(LeftCounts) | |
NRight = sum(RightCounts) | |
NTotal = float(NLeft + NRight) | |
LL = np.dot(LeftCounts,LeftCounts) | |
RR = np.dot(RightCounts,RightCounts) |
This file contains 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 dilate_naive(x, k): | |
m,n = x.shape | |
y = np.empty_like(x) | |
for i in xrange(m): | |
for j in xrange(n): | |
currmax = x[i,j] | |
for ii in xrange(max(0, i-k/2), min(m, i+k/2+1)): | |
for jj in xrange(max(0, j-k/2), min(n, j+k/2+1)): | |
elt = x[ii,jj] | |
if elt > currmax: |
This file contains 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 dilate_two_pass(x, k): | |
m,n = x.shape | |
y = np.empty_like(x) | |
for i in xrange(m): | |
for j in xrange(n): | |
left_idx = max(0, i-k/2) | |
right_idx = min(m, i+k/2+1) | |
currmax = x[left_idx, j] | |
for ii in xrange(left_idx+1, right_idx): | |
elt = x[ii, j] |
This file contains 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 dilate_two_pass(x, window_size): | |
m,n = x.shape | |
k,l = window_size | |
y = np.empty_like(x) | |
for i in xrange(m): | |
for j in xrange(n): | |
left_idx = max(0, i-k/2) | |
right_idx = min(m, i+k/2+1) | |
currmax = x[left_idx, j] | |
for ii in xrange(left_idx+1, right_idx): |
This file contains 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 dilate_naive(x, (k,l)): | |
m,n = x.shape | |
y = np.empty_like(x) | |
for i in xrange(m): | |
for j in xrange(n): | |
currmax = x[i,j] | |
for ii in xrange(max(0, i-k/2), min(m, i+k/2+1)): | |
for jj in xrange(max(0, j-l/2), min(n, j+l/2+1)): | |
elt = x[ii,jj] | |
if elt > currmax: |
This file contains 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 numpy_count_thresh(values, thresh): | |
return np.sum(values < thresh) |
NewerOlder