Skip to content

Instantly share code, notes, and snippets.

View aminnj's full-sized avatar

Nick Amin aminnj

  • Austin, TX
View GitHub Profile
@aminnj
aminnj / dygan.ipynb
Created September 18, 2018 22:10
dygan
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aminnj
aminnj / install_gpuxgboost.sh
Created September 23, 2018 00:41
installing xgboost with gpu support on uaf-1
# main instructions from https://xgboost.readthedocs.io/en/latest/build.html#building-with-gpu-support
# first install cmake somewhere
curl -O -L https://cmake.org/files/v3.12/cmake-3.12.0-Linux-x86_64.tar.gz
tar xf cmake*.tar.gz
cd cmake*/
export CMAKE_ROOT=`pwd`
# get 10X environment for slc7
cd /cvmfs/cms.cern.ch/slc7_amd64_gcc630/cms/cmssw/CMSSW_10_2_0_pre6/ ; cmsenv ; cd -
@aminnj
aminnj / excel.py
Last active September 30, 2018 22:28
excel-themed matplotlib plots
import os
import numpy as np
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
# matplotlib.font_manager._rebuild() # after installing calibri
from matplotlib import rcParams
from cycler import cycler
@aminnj
aminnj / parse_takeout.py
Last active October 29, 2018 01:59
Parse most of google takeout data into a single dataframe
import json
import numpy as np
import pandas as pd
pd.set_option('display.width', None)
def get_dfs(which=["android","assistant","chrome","gmail","playstore","image","maps","search","voice","location"]):
dfs = {}
def get_fname(name):
if "Location History" in name:
return "Takeout/Location History/Location History.json"
@aminnj
aminnj / character_widths.html
Last active November 22, 2018 00:07
javascript to measure character widths in semi-hacky way
<html>
<head>
<style>
body {
font: small/1.5 Arial,Helvetica,sans-serif;
letter-spacing: normal;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
@aminnj
aminnj / capacity.py
Created April 10, 2019 19:36
nn capacity
import numpy as np
# number of nodes per layer
nodes = np.array([2,3,4])
# upper bound on capacity according to eq 1.1 of https://arxiv.org/pdf/1901.00434.pdf
# pairwise product of nodes weighted by the minimum layer width up to that point
capacity = np.sum(np.minimum.accumulate(nodes)[:-1]*nodes[:-1]*nodes[1:])
print(capacity)
# a fully connected arch with equal number of nodes per layer will have a capacity
# that scales linearly with the total matrix multiplication time (is this true?)
@aminnj
aminnj / ttzbb.ipynb
Created April 23, 2019 01:16
ttZ (Z->bb) vs ttbar+bb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aminnj
aminnj / tfcudadocker.sh
Created July 1, 2019 22:19
tensorflow with cuda 10.0 in docker w/ virtualenv
# on uaf, use singularity to load docker. with `--nv` for nvidia stuff
singularity shell --bind /cvmfs --nv docker://tensorflow/tensorflow:latest-gpu-py3
[ -d virtualenv ] || pip install --target=`pwd`/virtualenv virtualenv
[ -d myenv ] || virtualenv/bin/virtualenv -p `which python` myenv
source myenv/bin/activate
pip install pydicom pandas numpy matplotlib scikit-learn scikit-image opencv-python-headless tensorflow-gpu keras jupyter tqdm
export TF_FORCE_GPU_ALLOW_GROWTH=true
jupyter notebook --no-browser --port=8880
@aminnj
aminnj / dump_pset_subset.py
Last active September 17, 2019 18:42
Dump a subset of a cmssw pset recursively
from pset_rawsim_onlyhlt import process
def recurse_coll(item,already_dumped=[]):
if hasattr(item,"_seq"):
print("process.{} = {}\n".format(item.label(),item.dumpPython()))
for thing in item._seq._collection:
for x in recurse_coll(thing): yield x
if hasattr(item,"_Parameterizable__parameterNames"):
if not item.label() in already_dumped:
print("process.{} = {}\n".format(item.label(),item.dumpPython()))
@aminnj
aminnj / download_psets.py
Last active September 23, 2019 21:15
Download psets for all tasks in a chain for a given dataset
from __future__ import print_function
import requests
import os
session = requests.Session()
session.cert = "/tmp/x509up_u{0}".format(os.getuid()) # should match `voms-proxy-info -path`
session.verify = "/etc/grid-security/certificates/" # or curl this locally: https://raw.githubusercontent.com/CMSTrackerDPG/cernrequests/master/cernrequests/cern-cacert.pem
def get_url_with_cert(url,params={}):
return session.get(url,params=params)