Skip to content

Instantly share code, notes, and snippets.

View davidhughhenrymack's full-sized avatar

David Mack davidhughhenrymack

  • Truckee
View GitHub Profile
@davidhughhenrymack
davidhughhenrymack / minception.py
Created July 26, 2018 19:59
A little idea to test out
import tensorflow as tf
'''
The mini-inception (mi) library
This is inspired by Google's inception network
and DARTS architecture search. I didn't get fancy
on the bilevel optimization, so let's see how it goes!!
def dynamic_assert_shape(tensor, shape):
"""
Check that a tensor has a shape given by a list of constants and tensor values.
This function will place an operation into your graph that gets executed at runtime.
This is helpful because often tensors have many dynamic sized dimensions that
you cannot otherwise compare / assert are as you expect.
For example, measure a dimension at run time:
@davidhughhenrymack
davidhughhenrymack / floydhub_hook.py
Created June 26, 2018 09:09
An easy way to graph your tensorflow metric ops in FloydHub
import tensorflow as tf
import numpy as np
class FloydHubMetricHook(tf.train.SessionRunHook):
"""An easy way to output your metric_ops to FloydHub's training metric graphs
This is designed to fit into TensorFlow's EstimatorSpec. Assuming you've
already defined some metric_ops for monitoring your training/evaluation,
this helper class will compute those operations then print them out in
@davidhughhenrymack
davidhughhenrymack / keras_symbolic_shapes.py
Last active December 24, 2017 15:31
A proposal for adding type-based symbolic shapes to keras
# This is a very rough early draft of something I think would help speed up my coding
# in Keras. I spend a reasonable amount of time reading the source code to work out
# how X method treats different dimensions, which largely seems to be by convention and
# only semi-documented. As someone new to these libraries, it'd help me a lot to make this
# explicit
# The rough idea is two fold:
# - Have "nanotypes" representing commonly used dimensions e.g. batch size
# - Allow Dimensions, and Shapes (a list of dimensions) to be type enforced