Skip to content

Instantly share code, notes, and snippets.

@Steven-N-Hart
Steven-N-Hart / explore_tfrecord.py
Created October 7, 2018 17:02
Need help debugging TFRecords? I know I do. I wrote this little script to explore TFRecords that I created to those provided by the community that I know work. I then can ensure that my records are not the cause.
tfrecord='path/2/tfrecord'
def _examine_tfrecord(tfrecord):
"""
This code will descend into the first record in a TFRecord file and print out the contents. I don't print our the image contents,
since that can get a little unwieldy. Also, If it is parsing an image mask file (that has a dense vector of classes for each pixel,
I summarize the contentents to make sure there isn't too much class imbalance.
"""
import tensorflow as tf
import io
@Steven-N-Hart
Steven-N-Hart / tf_lstm.py
Created September 21, 2017 02:10 — forked from siemanko/tf_lstm.py
Simple implementation of LSTM in Tensorflow in 50 lines (+ 130 lines of data generation and comments)
"""Short and sweet LSTM implementation in Tensorflow.
Motivation:
When Tensorflow was released, adding RNNs was a bit of a hack - it required
building separate graphs for every number of timesteps and was a bit obscure
to use. Since then TF devs added things like `dynamic_rnn`, `scan` and `map_fn`.
Currently the APIs are decent, but all the tutorials that I am aware of are not
making the best use of the new APIs.
Advantages of this implementation:
@Steven-N-Hart
Steven-N-Hart / ggplot_doubleY.R
Created August 24, 2016 15:31
Plot overlapping ggplots
#Plot any ggplot with 2 y-axes
#p1 and p2 are any plot objects from ggplot
ggplot_doubleY = function(p1,p2){
#Plot any ggplot with 2 y-axes
library(ggplot2)
library(gtable)
library(grid)
p2 = p2 + theme_bw() %+replace% theme(panel.background = element_rect(fill = NA))