3 Draw a graph of the net architecture.
5 from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
6 from google.protobuf import text_format
10 from caffe.proto import caffe_pb2
14 """Parse input arguments
17 parser = ArgumentParser(description=__doc__,
18 formatter_class=ArgumentDefaultsHelpFormatter)
20 parser.add_argument('input_net_proto_file',
21 help='Input network prototxt file')
22 parser.add_argument('output_image_file',
23 help='Output image file')
24 parser.add_argument('--rankdir',
25 help=('One of TB (top-bottom, i.e., vertical), '
26 'RL (right-left, i.e., horizontal), or another '
27 'valid dot option; see '
28 'http://www.graphviz.org/doc/info/'
29 'attrs.html#k:rankdir'),
31 parser.add_argument('--phase',
32 help=('Which network phase to draw: can be TRAIN, '
33 'TEST, or ALL. If ALL, then all layers are drawn '
34 'regardless of phase.'),
37 args = parser.parse_args()
43 net = caffe_pb2.NetParameter()
44 text_format.Merge(open(args.input_net_proto_file).read(), net)
45 print('Drawing net to %s' % args.output_image_file)
47 if args.phase == "TRAIN":
49 elif args.phase == "TEST":
51 elif args.phase != "ALL":
52 raise ValueError("Unknown phase: " + args.phase)
53 caffe.draw.draw_net_to_file(net, args.output_image_file, args.rankdir,
57 if __name__ == '__main__':