Create a TensorFlow Hub module for testing. Args: save_path: The directory path in which to save the model.
(save_path)
| 126 | |
| 127 | |
| 128 | def _create_hub_module(save_path): |
| 129 | """Create a TensorFlow Hub module for testing. |
| 130 | |
| 131 | Args: |
| 132 | save_path: The directory path in which to save the model. |
| 133 | """ |
| 134 | # Module function that doubles its input. |
| 135 | def double_module_fn(): |
| 136 | w = tf.Variable([2.0, 4.0]) |
| 137 | x = tf.compat.v1.placeholder(dtype=tf.float32) |
| 138 | hub.add_signature(inputs=x, outputs=x*w) |
| 139 | graph = tf.Graph() |
| 140 | with graph.as_default(): |
| 141 | spec = hub.create_module_spec(double_module_fn) |
| 142 | m = hub.Module(spec) |
| 143 | # Export the module. |
| 144 | with tf.compat.v1.Session(graph=graph) as sess: |
| 145 | sess.run(tf.compat.v1.global_variables_initializer()) |
| 146 | m.export(save_path, sess) |
| 147 | |
| 148 | def _create_frozen_model(save_path): |
| 149 | graph = tf.Graph() |
no test coverage detected
searching dependent graphs…