Imported from https://github.com/rickyHong/Puzzle-tensorflow-latest-repl