This file contains hidden or 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
| 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 |
This file contains hidden or 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
| """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: |
This file contains hidden or 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
| #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)) |