| 90 | |
| 91 | class TestSlimModels(unittest.TestCase): |
| 92 | def test_graph(self): |
| 93 | with tf.Session(): |
| 94 | with tf.Graph().as_default() as g: |
| 95 | nets.vgg.vgg_16(tf.placeholder(tf.float32, shape=(1, 224, 224, 3))) |
| 96 | dot = hl.build_graph(g).build_dot() |
| 97 | dot.format = 'pdf' |
| 98 | dot.render("tf_vgg16", directory=OUTPUT_DIR, cleanup=True) |
| 99 | |
| 100 | with tf.Session(): |
| 101 | with tf.Graph().as_default() as g: |
| 102 | nets.resnet_v1.resnet_v1_50( |
| 103 | tf.placeholder(tf.float32, shape=(1, 224, 224, 3))) |
| 104 | dot = hl.build_graph(g).build_dot() |
| 105 | dot.format = 'pdf' |
| 106 | dot.render("tf_resnet50", directory=OUTPUT_DIR, cleanup=True) |
| 107 | |
| 108 | with tf.Session(): |
| 109 | with tf.Graph().as_default() as g: |
| 110 | nets.inception.inception_v1( |
| 111 | tf.placeholder(tf.float32, shape=(1, 224, 224, 3))) |
| 112 | dot = hl.build_graph(g).build_dot() |
| 113 | dot.format = 'pdf' |
| 114 | dot.render("tf_inception", directory=OUTPUT_DIR, cleanup=True) |
| 115 | |
| 116 | with tf.Session(): |
| 117 | with tf.Graph().as_default() as g: |
| 118 | nets.alexnet.alexnet_v2( |
| 119 | tf.placeholder(tf.float32, shape=(1, 224, 224, 3))) |
| 120 | dot = hl.build_graph(g).build_dot() |
| 121 | dot.format = 'pdf' |
| 122 | dot.render("tf_alexnet", directory=OUTPUT_DIR, cleanup=True) |
| 123 | |
| 124 | with tf.Session(): |
| 125 | with tf.Graph().as_default() as g: |
| 126 | nets.overfeat.overfeat( |
| 127 | tf.placeholder(tf.float32, shape=(1, 231, 231, 3))) |
| 128 | dot = hl.build_graph(g).build_dot() |
| 129 | dot.format = 'pdf' |
| 130 | dot.render("tf_overfeat", directory=OUTPUT_DIR, cleanup=True) |
| 131 | |
| 132 | # Clean up |
| 133 | shutil.rmtree(OUTPUT_DIR) |
| 134 | |
| 135 | |
| 136 | if __name__ == "__main__": |