(save_path)
| 146 | m.export(save_path, sess) |
| 147 | |
| 148 | def _create_frozen_model(save_path): |
| 149 | graph = tf.Graph() |
| 150 | saved_model_dir = os.path.join(save_path) |
| 151 | with graph.as_default(): |
| 152 | x = tf.constant([[37.0, -23.0], [1.0, 4.0]]) |
| 153 | w = tf.Variable(tf.random.uniform([2, 2])) |
| 154 | y = tf.matmul(x, w) |
| 155 | tf.nn.softmax(y) |
| 156 | init_op = w.initializer |
| 157 | |
| 158 | # Create a builder |
| 159 | builder = saved_model.builder.SavedModelBuilder( |
| 160 | saved_model_dir) |
| 161 | |
| 162 | with tf.compat.v1.Session() as sess: |
| 163 | # Run the initializer on `w`. |
| 164 | sess.run(init_op) |
| 165 | |
| 166 | builder.add_meta_graph_and_variables( |
| 167 | sess, [saved_model.tag_constants.SERVING], |
| 168 | signature_def_map=None, |
| 169 | assets_collection=None) |
| 170 | |
| 171 | builder.save() |
| 172 | |
| 173 | frozen_file = os.path.join(save_path, 'frozen.pb') |
| 174 | freeze_graph.freeze_graph( |
| 175 | '', |
| 176 | '', |
| 177 | True, |
| 178 | '', |
| 179 | "Softmax", |
| 180 | '', |
| 181 | '', |
| 182 | frozen_file, |
| 183 | True, |
| 184 | '', |
| 185 | saved_model_tags=saved_model.tag_constants.SERVING, |
| 186 | input_saved_model_dir=saved_model_dir) |
| 187 | class APIAndShellTest(tf.test.TestCase): |
| 188 | """Tests for the Python API of the pip package.""" |
| 189 |
no test coverage detected
searching dependent graphs…