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
np.random.seed(42) | |
random.seed(42) | |
cudnn.benchmark = False | |
cudnn.deterministic = True | |
torch.manual_seed(42) | |
torch.cuda.manual_seed_all(42) | |
torch.set_printoptions(precision=10) |
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
jupyter nbconvert --ClearOutputPreprocessor.enabled=True --inplace Notebook.ipynb |
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(open) { | |
XMLHttpRequest.prototype.open = function(method, URL, async, user, password) { | |
if (URL.indexOf("xxxx") > -1) { | |
// console.log(method, URL, async, user, password); | |
this.addEventListener('readystatechange', function () { | |
if(this.responseText !== '' && this.readyState == 4) { | |
var oldResponseText = this.responseText; | |
// ... | |
var newResponseText = 'blabla'; | |
Object.defineProperty(this, 'responseText', { |
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
for file in $(find ../../files/ -name '*.pkl') | |
do | |
name=${file##*/} | |
name=${name%.*} | |
name=${name/"_xxxx"/"_zzzzz"} | |
folder=$(dirname ${file}) | |
python -u pkl_to_json.py -i "${file}" -o "${folder}/${name}.json" | |
done |
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
files = [os.path.join(r, f) for r, d, fs in os.walk(PATH) for f in fs if f.endswith('.png')] |
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
conda uninstall --force pillow -y | |
# install libjpeg-turbo to $HOME/turbojpeg | |
git clone https://github.com/libjpeg-turbo/libjpeg-turbo | |
pushd libjpeg-turbo | |
mkdir build | |
cd build | |
cmake .. -DCMAKE_INSTALL_PREFIX:PATH=$HOME/turbojpeg | |
make | |
make install |
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 tempfile | |
from keras.models import load_model | |
from keras import activations | |
from keras.layers import Activation | |
def split_last_layer(model): | |
def apply_modifications(model, custom_objects=None): | |
model_path = os.path.join(tempfile.gettempdir(), next(tempfile._get_candidate_names()) + '.h5') | |
try: | |
model.save(model_path) |
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 os | |
import keras.backend as K | |
from keras.models import load_model, model_from_json | |
import numpy as np | |
import json | |
def switch_backend(backend): | |
if backend == 'theano': | |
# os.environ['KERAS_BACKEND'] = 'theano' |
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
''' | |
Code from https://medium.com/mlreview/a-guide-to-receptive-field-arithmetic-for-convolutional-neural-networks-e0f514068807 | |
''' | |
import math | |
# [kernel_size, stride, pad_size], ... | |
convnet = [[8, 1, 0], [2, 2, 0], | |
[5, 1, 0], [2, 2, 0], | |
[3, 1, 0], [2, 2, 0], | |
[2, 1, 0], [2, 2, 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
from subprocess import Popen, PIPE | |
import pandas as pd | |
SYMBOLS = { | |
'customary': ('B', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'), | |
'customary_ext': ('byte', 'kilo', 'mega', 'giga', 'tera', 'peta', 'exa', | |
'zetta', 'iotta'), | |
'iec': ('Bi', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi', 'Yi'), | |
'iec_60027_2': ('BiB', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', | |
'YiB'), |