forked from olantwin/calopid
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_model.py
More file actions
30 lines (24 loc) · 930 Bytes
/
plot_model.py
File metadata and controls
30 lines (24 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python
# coding: utf-8
"""Plot model architecture."""
import argparse
import logging
import os.path
from tensorflow.keras.models import load_model
from tensorflow.keras.utils import plot_model
def main():
"""Plot model architecture."""
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("model", help="""File containing the model to plot.""")
parser.add_argument(
"-o", "--output_dir", help="""Output directory for plots.""", default="plots"
)
args = parser.parse_args()
model = load_model(args.model)
model_name = "_".join(os.path.split(args.model)[-1].split("_")[:3])
model.summary()
plot_model(model, show_shapes=True, to_file=f"{args.output_dir}/{model_name}.png")
plot_model(model, show_shapes=True, to_file=f"{args.output_dir}/{model_name}.pdf")
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
main()