Skip to content

Instantly share code, notes, and snippets.

View rreece's full-sized avatar
🙈
doing things

Ryan Reece rreece

🙈
doing things
View GitHub Profile
#!/usr/bin/env python
# Set up ROOT and RootCore
import ROOT
ROOT.gROOT.Macro('$ROOTCOREDIR/scripts/load_packages.C')
# Initialize the xAOD infrastructure
ROOT.xAOD.Init()
# Set up the input files (PDSF)
@rreece
rreece / rootnotes.py
Last active August 29, 2015 14:17 — forked from mazurov/rootnotes.py
"""
Helper module for displaying ROOT canvases in ipython notebooks
Usage example:
# Save this file as rootnotes.py to your working directory.
import rootnotes
c1 = rootnotes.default_canvas()
fun1 = TF1( 'fun1', 'abs(sin(x)/x)', 0, 10)
c1.SetGridx()
@rreece
rreece / np_to_tfrecords.py
Created June 21, 2018 02:12 — forked from swyoon/np_to_tfrecords.py
From numpy ndarray to tfrecords
import numpy as np
import tensorflow as tf
__author__ = "Sangwoong Yoon"
def np_to_tfrecords(X, Y, file_path_prefix, verbose=True):
"""
Converts a Numpy array (or two Numpy arrays) into a tfrecord file.
For supervised learning, feed training inputs to X and training labels to Y.
For unsupervised learning, only feed training inputs to X, and feed None to Y.
@rreece
rreece / mv_files.sh
Created June 27, 2018 18:34
Bash script to continuously watch for output files and move them
#!/usr/bin/env bash
log=mv_files.log
spare=/spare/ryan
dest=/cb/data/imagenet1k2/new/
while true; do
if test -n "$(shopt -s nullglob; echo $spare/*)"
then
echo "Moving files to $dest"
echo "Moving files to $dest" >> $log
ls -rt1 $spare | head -n -10 | xargs -n 1 echo
@rreece
rreece / brew_install_python3.sh
Created August 4, 2018 20:50
Installing python3 on Mac OSX
# Installing python3 on Mac OSX
brew install python3
# Error: An unexpected error occurred during the `brew link` step
# The formula built, but is not symlinked into /usr/local
# Permission denied @ dir_s_mkdir - /usr/local/Frameworks
# Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks
#
# See: https://github.com/Homebrew/homebrew-core/issues/19286
@rreece
rreece / latin1_to_ascii
Last active August 7, 2018 20:20
convert unicode to ascii
#!/usr/bin/env python2
"""
FROM: http://code.activestate.com/recipes/251871/
latin1_to_ascii -- The UNICODE Hammer -- AKA "The Stupid American"
This takes a UNICODE string and replaces Latin-1 characters with
something equivalent in 7-bit ASCII. This returns a plain ASCII string.
This function makes a best effort to convert Latin-1 characters into
ASCII equivalents. It does not just strip out the Latin1 characters.
@rreece
rreece / min-char-rnn.py
Last active August 13, 2018 18:34 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
#!/usr/bin/env python3
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
#!/usr/bin/env sh
# This scripts downloads the mnist data and unzips it.
DIR="$( cd "$(dirname "$0")" ; pwd -P )"
cd "$DIR"
echo "Downloading..."
for fname in train-images-idx3-ubyte train-labels-idx1-ubyte t10k-images-idx3-ubyte t10k-labels-idx1-ubyte
do
@rreece
rreece / save_pbtxt.py
Last active September 13, 2018 20:01
import tensorflow as tf
from google.protobuf import text_format
##______________________________________________________________________________
def model_fn(features, labels, mode, params, pbtxt):
...
optimizer = tf.train.AdamOptimizer(learning_rate=params['lr'])
train_op = optimizer.minimize(loss, global_step=tf.train.get_global_step())
@rreece
rreece / tf-experiment-template.py
Created August 13, 2018 23:57 — forked from damienpontifex/tf-experiment-template.py
A template for a custom tensorflow estimator and experiment with python3 typings for desired parameter types
import argparse
import psutil
import tensorflow as tf
from typing import Dict, Any, Callable, Tuple
## Data Input Function
def data_input_fn(data_param,
batch_size:int=None,
shuffle=False) -> Callable[[], Tuple]:
"""Return the input function to get the test data.