Imported from https://github.com/Stick-To/DLA-tensorflow