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
function download_google_drive { | |
SRC=$1 | |
DST=$2 | |
echo "$SRC -> $DST" | |
curl -c /tmp/cookies "https://drive.google.com/uc?export=download&id=$SRC" > /tmp/intermezzo.html | |
DL_LINK=$(cat /tmp/intermezzo.html |\ | |
grep -Po 'uc-download-link" [^>]* href="\K[^"]*' |\ | |
sed 's/\&/\&/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
import numpy as np | |
from numba import njit, parallel | |
@njit(parallel=True) | |
def cross_exchange(route1, route2, dist): | |
best_savings = -np.inf | |
for offset11 in prange(len(route1) - 3): | |
i1, i2 = route1[offset11], route1[offset11 + 1] | |
dii = dist[i1, i2] | |
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
import ee | |
import urllib | |
import numpy as np | |
from skimage import io | |
from PIL import Image | |
from zipfile import ZipFile | |
from matplotlib import pyplot as plt | |
ee.Initialize() |
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
#!/usr/bin/env python | |
""" | |
fast_argmax.py | |
""" | |
import numpy as np | |
from time import time | |
from numba import jit, prange |
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
#!/usr/bin/env python | |
""" | |
prep-CUB200.py | |
""" | |
import os | |
import shutil | |
import pandas as pd | |
from tqdm import tqdm |
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 rle2mask(rle, height, width): | |
rle = [int(xx) for xx in rle.split(' ')] | |
offsets, runs = rle[0::2], rle[1::2] | |
tmp = np.zeros(height * width, dtype=np.uint8) | |
for offset, run in zip(offsets, runs): | |
tmp[offset:offset + run] = 1 | |
return tmp.reshape(width, height).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
// Note: `@` refers to matrix-matrix or matrix-vector multiplication. `*` refers to elementwise multiplication. | |
degrees = // vector s.t. degree[i] is the degree of the i'th node in graph G | |
D = // diagonal matrix s.t. D[i, i] = degrees[i] | |
D_inv = // diagonal matrix s.t. D_inv[i, i] = 1 / sqrt(degrees[i]) | |
q = // zero matrix of shape (max_iters, num_nodes) | |
grad = -alpha * D_inv @ s | |
while k < max_iters do |
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
#!/usr/bin/env python | |
""" | |
simple_batchnorm.py | |
""" | |
class SimpleBatchNorm1d(nn.Module): | |
def __init__(self, dim, momentum=0.5, eps=1e-5, affine=True, track_running_stats=True): | |
self.eps = eps | |
self.momentum = momentum |
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
#!/usr/bin/env python | |
""" | |
sgd_optimizers.py | |
Pseudocode for optimizers | |
These _should be_ identical to Pytorch implementation of the optimizers | |
""" |
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
#!/usr/bin/env python | |
""" | |
simple-random-nasbench.py | |
""" | |
import numpy as np | |
import pandas as pd | |
from tqdm import tqdm, trange | |
from matplotlib import pyplot as plt |
NewerOlder