summaryrefslogtreecommitdiff
path: root/res/TensorFlowPythonExamples/tfpem.py
diff options
context:
space:
mode:
Diffstat (limited to 'res/TensorFlowPythonExamples/tfpem.py')
-rwxr-xr-xres/TensorFlowPythonExamples/tfpem.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/res/TensorFlowPythonExamples/tfpem.py b/res/TensorFlowPythonExamples/tfpem.py
new file mode 100755
index 000000000..514200c19
--- /dev/null
+++ b/res/TensorFlowPythonExamples/tfpem.py
@@ -0,0 +1,25 @@
+# TensorFlow Python Example Manager
+
+import tensorflow as tf
+import importlib
+import argparse
+
+parser = argparse.ArgumentParser(description='Process TensorFlow Python Examples')
+
+parser.add_argument('--mode', metavar='MODE', choices=['pbtxt'], default='pbtxt')
+parser.add_argument('examples', metavar='EXAMPLES', nargs='+')
+
+args = parser.parse_args()
+
+if args.mode == 'pbtxt':
+ for example in args.examples:
+ print("Generate '" + example + ".pbtxt'")
+
+ tf.compat.v1.reset_default_graph()
+ # https://stackoverflow.com/questions/37808866/proper-way-to-dynamically-import-a-module-with-relative-imports
+ importlib.import_module("examples." + example)
+
+ with open(example + ".pbtxt", "w") as f:
+ f.write(str(tf.compat.v1.get_default_graph().as_graph_def(add_shapes=True)))
+
+ print("Generate '" + example + ".pbtxt' - Done")