Skip to content

Instantly share code, notes, and snippets.

View planetceres's full-sized avatar

Matt Shaffer planetceres

View GitHub Profile
@planetceres
planetceres / adaboost.py
Created September 24, 2016 00:00 — forked from tristanwietsma/adaboost.py
AdaBoost Python implementation of the AdaBoost (Adaptive Boosting) classification algorithm.
from __future__ import division
from numpy import *
class AdaBoost:
def __init__(self, training_set):
self.training_set = training_set
self.N = len(self.training_set)
self.weights = ones(self.N)/self.N
self.RULES = []
@planetceres
planetceres / conda_backup_env.sh
Last active March 27, 2018 21:27
[Deprecated] Backup all Anaconda environments `bash conda_backup_env.sh <folder path for backup>`
#!/bin/bash
NOW=$(date "+%Y-%m-%d")
DIR=$1
mkdir $DIR/envs-$NOW
ENVS=$(conda env list | grep '^\w' | cut -d' ' -f1)
for env in $ENVS; do
source activate $env
conda env export > $DIR/envs-$NOW/$env.yml
echo "Exporting $env to .yml"
@planetceres
planetceres / conda_remove_all.sh
Last active March 27, 2018 21:27
[Deprecated] Remove all Anaconda environments with prompt `bash conda_remove_all.sh`
#!/bin/bash
ENVS=$(conda env list | grep '^\w' | cut -d' ' -f1)
for env in $ENVS; do
conda remove -n $env --all
echo "Removing $env"
done
@planetceres
planetceres / conda_export_all.sh
Last active March 27, 2018 21:27
Export all conda env to environment.yml `bash conda_export_all.sh <folder path for backup>`
#!/bin/bash
. ~/anaconda3/etc/profile.d/conda.sh
NOW=$(date "+%Y-%m-%d")
if [ $1 -eq 0 ]; then
DIR='~/Desktop/condas/'
else
DIR=$1
fi
@planetceres
planetceres / conda_remove_all.sh
Last active March 27, 2018 21:28
Remove all conda environmets 'bash conda_remove_all.sh'
#!/bin/bash
. ~/anaconda3/etc/profile.d/conda.sh
ENVS=$(conda env list | grep '^\w' | cut -d' ' -f1)
for env in $ENVS; do
conda remove -n $env --all
echo "Removing $env"
done
@planetceres
planetceres / horovod_cluster_setup.md
Last active March 5, 2020 20:56
Horovod Cluster Setup with CUDA 9.0, Miniconda3 and Tensorflow 1.8rc

Setup of GPU Enabled VM for Distributed Tensorflow using Horovod

Update CentOS

Update CentOS and reboot (you will need to login again):

sudo yum update -y
sudo reboot
@planetceres
planetceres / tf_1-8_keras_2-1_gpu_setup.md
Created July 23, 2018 06:11
Provision Ubuntu 16.04 with CUDA 9.0 CUDNN 7.1.4 Tensorflow 1.8.0 Keras 2.1.5

Requirements

  • OS
    • Ubuntu 16.04
  • CUDA
    • CUDA 9.0
    • NVCC 9.0.176
    • CUDNN 7.1.4
  • Tensorflow
    • GPU 1.8.0
@planetceres
planetceres / rgb_from_prob.py
Created August 17, 2018 04:16
RGB values from probability value in range (0,1)
def rgb_from_prob(value, minimum=0, maximum=1):
'''
Based on: https://stackoverflow.com/a/20792531/3450793
'''
minimum, maximum = float(minimum), float(maximum)
ratio = 2 * (value-minimum) / (maximum - minimum)
g = int(max(0, 255*(1 - ratio)))
r = int(max(0, 255*(ratio - 1)))
b = 255 - g - r
@planetceres
planetceres / useful_pandas_snippets.py
Last active August 21, 2018 18:10 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
# List unique values in a DataFrame column
# h/t @makmanalp for the updated syntax!
df['Column Name'].unique()
# Convert Series datatype to numeric (will error if column has non-numeric values)
# h/t @makmanalp
pd.to_numeric(df['Column Name'])
# Convert Series datatype to numeric, changing non-numeric values to NaN
# h/t @makmanalp for the updated syntax!
@planetceres
planetceres / cython_line_profiler.ipynb
Last active October 31, 2018 18:24 — forked from tillahoffmann/cython_line_profiler.ipynb
Demonstration of line-by-line profiling for `cython` functions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.