This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |