Skip to content

Instantly share code, notes, and snippets.

Avatar

Collin Donahue-Oponski colllin

View GitHub Profile
@colllin
colllin / Readme.md
Last active Mar 14, 2019
Example startup script / boot script "user data" for running machine learning experiments on EC2 Spot Instances with git & dvc
View Readme.md

Prerequisites

  • Write your training script so that it can be killed, and then automatically resumes from the beginning of the current epoch when restarted. (See train-example.py for an example training loop incorporating these recommendations.)
    • Save checkpoints at every epoch... (See utils.py for save_training_state helper function.)
      • model(s)
      • optimizer(s)
      • any hyperparameter schedules — I usually write the epoch number to a JSON file and compute the hyperparameter schedules as a function of the epoch number.
    • At the beginning of training, check for any saved training checkpoints and load all relevent info (models, optimizers, hyperparameter schedules). (See utils.py for load_training_state helper function.)
    • Consider using smaller epochs by limiting the number of batches pulled from your (shuffled) dataloader during each epoch.
      • This will cause your trai
@colllin
colllin / README.md
Created Dec 31, 2018
Deep Learning Base AMI setup script
View README.md

Development Setup

$ sudo add-apt-repository ppa:jonathonf/python-3.6
$ sudo apt update
$ sudo apt install python3.6 python3.6-dev
$ wget https://bootstrap.pypa.io/get-pip.py
$ python3.6 get-pip.py
$ rm get-pip.py
$ sudo pip3.6 install pipenv
@colllin
colllin / ec2__setting-up-raid__useful-commands.sh
Last active Oct 29, 2018
Setting up raid on EC2 instance
View ec2__setting-up-raid__useful-commands.sh
# xvdg1 and xvdh1 are 2 attached volumes; md0 will be the (virtual) raid volume
mdadm -C /dev/md0 -l raid0 -c 64 -n 2 /dev/xvdg1 /dev/xvdh1
mdadm -E /dev/xvd[g-h]1
mdadm --detail /dev/md0
mkfs.ext4 /dev/md0
df -h
mount /dev/md0 /mnt/
@colllin
colllin / Readme.md
Last active May 28, 2019
Install NVIDIA drivers & CUDA
View Readme.md
  1. Install NVIDIA drivers

    1. Find NVIDIA driver download link for your system at http://www.nvidia.com/Download/index.aspx?lang=en-us

    2. wget -P ~/Downloads/ http://us.download.nvidia.com/tesla/390.46/NVIDIA-Linux-x86_64-390.46.run

    3. sudo rm /etc/X11/xorg.conf # It's ok if this doesn't exist

    4. NVIDIA will clash with the nouveau driver so deactivate it:

      $ sudo vim /etc/modprobe.d/blacklist-nouveau.conf
      
@colllin
colllin / adamw.py
Last active Jan 1, 2020
PyTorch AdamW optimizer
View adamw.py
# Based on https://github.com/pytorch/pytorch/pull/3740
import torch
import math
class AdamW(torch.optim.Optimizer):
"""Implements AdamW algorithm.
It has been proposed in `Fixing Weight Decay Regularization in Adam`_.
Arguments:
@colllin
colllin / install.md
Last active Aug 29, 2019
Setup EC2 for RL OpenAI Gym
View install.md
@colllin
colllin / globalmaptiles.py
Last active Nov 29, 2017 — forked from tucotuco/globalmaptiles.py
Classes to calculate Tile coordinates
View globalmaptiles.py
# From https://gist.github.com/colllin/c02319fe3202470cc4d0a0b73cdbd1a6
#!/usr/bin/env python
###############################################################################
# $Id$
#
# Project: GDAL2Tiles, Google Summer of Code 2007 & 2008
# Global Map Tiles Classes
# Purpose: Convert a raster into TMS tiles, create KML SuperOverlay EPSG:4326,
# generate a simple HTML viewers based on Google Maps and OpenLayers
@colllin
colllin / capsule_networks.py
Created Nov 21, 2017 — forked from kendricktan/capsule_networks.py
Clean Code for Capsule Networks
View capsule_networks.py
"""
Dynamic Routing Between Capsules
https://arxiv.org/abs/1710.09829
"""
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
import torchvision.transforms as transforms
@colllin
colllin / 1 - Find UTM Zone of source data .sh
Last active Nov 27, 2019
GDAL: Convert from UTM Zone to Lat/Lon (EPSG:4326)
View 1 - Find UTM Zone of source data .sh
$ gdalsrsinfo source.shp
PROJ.4 : '+proj=utm +zone=34 +south +datum=WGS84 +units=m +no_defs '
OGC WKT :
PROJCS["WGS_1984_UTM_Zone_34S",
GEOGCS["GCS_WGS_1984",
DATUM["WGS_1984",
SPHEROID["WGS_84",6378137,298.257223563]],
PRIMEM["Greenwich",0],
@colllin
colllin / jupyter_notebook_config.py
Created Sep 20, 2017
Jupyter Example of c.NotebookApp.login_handler_class
View jupyter_notebook_config.py
# From https://github.com/vlimant/caltech-jupyter/blob/0b113c4aac26d41a35c82c8214351b89b6e80ae5/jupyter/jupyter_notebook_config.py
import os
import json
# Configuration file for jupyter-notebook.
#------------------------------------------------------------------------------
# Configurable configuration
#------------------------------------------------------------------------------