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
#!/bin/bash | |
set -eu | |
SYSCTL_FILE=/etc/sysctl.d/90-tcp-bbr.conf | |
# check root | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run as root" | |
exit 1 | |
fi |
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
#put the these lines before importing any module from keras. | |
import tensorflow as tf | |
from keras.backend.tensorflow_backend import set_session | |
config = tf.ConfigProto() | |
config.gpu_options.allow_growth = True | |
config.gpu_options.visible_device_list = "0" #only the gpu 0 is allowed | |
set_session(tf.Session(config=config)) |
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 https://stackoverflow.com/questions/38250710/how-to-split-data-into-3-sets-train-validation-and-test | |
def train_validate_test_split(df, train_percent=.6, validate_percent=.2, seed=None): | |
np.random.seed(seed) | |
perm = np.random.permutation(df.index) | |
m = len(df.index) | |
train_end = int(train_percent * m) | |
validate_end = int(validate_percent * m) + train_end | |
train = df.ix[perm[:train_end]] | |
validate = df.ix[perm[train_end:validate_end]] | |
test = df.ix[perm[validate_end:]] |
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 multi_array_shuffle(*arrays, random_state=1): | |
array_length = arrays[0].shape[0] | |
permutated = [] | |
np.random.seed(random_state) | |
permutation = np.random.permutation(array_length) | |
for array in arrays: | |
permutated.append(array[permutation, ...]) | |
return permutated | |
def cv_model_func(model_func, inputs, targets, scores_func, label=None, seed=1, fold=5, **kwargs): |
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 | |
import pandas as pd | |
from keras.callbacks import Callback | |
class ScoreMetric(Callback): | |
def __init__(self, score_func, num_input=1, num_target=1): | |
super(ScoreMetric, self).__init__() | |
self.num_input = num_input | |
self.num_target = num_target | |
self.score_func = score_func |
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 bibtexparser | |
from bibtexparser.bparser import BibTexParser | |
from bibtexparser.customization import convert_to_unicode | |
def parse_author(auth_str): | |
auth_str_authors = auth_str.split(" and ") | |
authors = [] | |
for author in auth_str_authors: | |
if "," in author: |
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
#!/bin/bash | |
sudo apt-get update | |
sudo apt-get install -y \ | |
apt-transport-https \ | |
ca-certificates \ | |
curl \ | |
software-properties-common | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
sudo add-apt-repository \ | |
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \ |
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 sklearn.ensemble import RandomForestClassifier | |
from sklearn.ensemble import AdaBoostClassifier | |
from sklearn.model_selection import KFold | |
from sklearn.metrics import roc_auc_score | |
import pandas as pd | |
import numpy as np | |
import os | |
from matplotlib import pyplot as plt | |
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 hashlib | |
def md5(fname): | |
hash_md5 = hashlib.md5() | |
with open(fname, "rb") as f: | |
for chunk in iter(lambda: f.read(4096), b""): | |
hash_md5.update(chunk) | |
return hash_md5.hexdigest() | |
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 nvidia/cuda:9.0-cudnn7-devel-ubuntu16.04 | |
ARG PYTHON_VERSION=3.6 | |
# workaround of the gpg error. see https://github.com/NVIDIA/nvidia-docker/issues/619 | |
RUN rm /etc/apt/sources.list.d/cuda.list | |
# use the source of tuna | |
RUN sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g;s/security.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list | |
RUN sed -i 's/http/https/g' /etc/apt/sources.list | |
#for mongodb |
OlderNewer