$ xvfb-run -s "-screen 0 1400x900x24" jupyter notebook
import matplotlib.pyplot as plt
%matplotlib inline
def show_state(env, step=0):
| """A context manager for enforcing (integer) timeouts of a code block.""" | |
| import contextlib | |
| @contextlib.contextmanager | |
| def Timeout(timeout: Optional[int]) -> ContextManager[None]: | |
| """Raises TimeoutError() if block isn't completed within `timeout` seconds. | |
| Args: | |
| timeout: Seconds. If None, there is no timeout. |
| def combined_legend(*axes): | |
| """Creates combines legends from provided axes. | |
| Usually used for ax and ax.twinx() | |
| """ | |
| lines, labels = [], [] | |
| for ax in axes: | |
| line, label = ax.get_legend_handles_labels() | |
| lines.extend(line) | |
| labels.extend(label) |
| #!/bin/bash | |
| CUDNN_FILE="cudnn-9.2-linux-x64-v7.1.tgz" | |
| [ -e $CUDNN_FILE ] || echo "Please download CUDNN 7.1 from https://developer.nvidia.com/rdp/cudnn-download" && exit 1 | |
| sudo apt-get install linux-headers-$(uname -r) | |
| # get CUDA 9.0 toolkit | |
| PKG="cuda-repo-ubuntu1604_9.2.88-1_amd64.deb" | |
| wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/$PKG |
| # From https://github.com/fchollet/keras/issues/5400#issuecomment-314747992 | |
| from keras import backend as K | |
| def mcor(y_true, y_pred): | |
| #matthews_correlation | |
| y_pred_pos = K.round(K.clip(y_pred, 0, 1)) | |
| y_pred_neg = 1 - y_pred_pos | |
| y_pos = K.round(K.clip(y_true, 0, 1)) |
| #!/bin/bash | |
| ENV=${1:-"$CONDA_DEFAULT_ENV"} | |
| if [ -z "$ENV" ]; then | |
| echo Must specify conda environment | |
| exit 1 | |
| fi | |
| DISPLAY_NAME=${2:-$ENV} | |
| echo Installing kernel for enviroment $ENV using display name \"$DISPLAY_NAME\" |
| #!/bin/bash | |
| # install CUDA Toolkit v8.0 | |
| # instructions from https://developer.nvidia.com/cuda-downloads (linux -> x86_64 -> Ubuntu -> 16.04 -> deb (network)) | |
| CUDA_REPO_PKG="cuda-repo-ubuntu1604_8.0.61-1_amd64.deb" | |
| wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/${CUDA_REPO_PKG} | |
| sudo dpkg -i ${CUDA_REPO_PKG} | |
| sudo apt-get update | |
| sudo apt-get -y install cuda |
| #!/bin/bash | |
| ssh $@ -t -- 'tmux a || tmux new-session' |
| from keras.callbacks import LearningRateScheduler | |
| def scheduler(schedule): | |
| def lr_schedule(epoch): | |
| epoch += 1 | |
| for ep,lr in sorted(schedule, reverse=True): | |
| if epoch >= ep: | |
| return lr | |
| raise ValueError() | |
| return lr_schedule |
| " If using YADR: ~/.vim/settings/path.vim | |
| " Or else in .vimrc | |
| set shell=/bin/zsh\ -l |