title: Freezing graph to pb in Tensorflow2
body: <p>We deploy lot of our models from TF1 by saving them through graph freezing:</p>
  
  <pre><code>tf.train.write_graph(self.session.graph_def, some_path)
  
  # get graph definitions with weights
  output_graph_def = tf.graph_util.convert_variables_to_constants(
          self.session,  # The session is used to retrieve the weights
          self.session.graph.as_graph_def(),  # The graph_def is used to retrieve the nodes
          output_nodes,  # The output node names are used to select the usefull nodes
  )
  
  # optimize graph
  if optimize:
      output_graph_def = optimize_for_inference_lib.optimize_for_inference(
              output_graph_def, input_nodes, output_nodes, tf.float32.as_datatype_enum
      )
  
  with open(path, "wb") as f:
      f.write(output_graph_def.SerializeToString())
  </code></pre>
  
  <p>and then loading them through:</p>
  
  <pre><code>with tf.Graph().as_default() as graph:
      with graph.device("/" + args[name].processing_unit):
          tf.import_graph_def(graph_def, name="")
              for key, value in inputs.items():
                  self.input[key] = graph.get_tensor_by_name(value + ":0")
  </code></pre>
  
  <p>We would like to save TF2 models in similar way. One protobuf file which will include graph and weights. How can I achieve this?</p>
  
  <p>I know that there are some methods for saving:</p>
  
  <ul>
  <li><p><code>keras.experimental.export_saved_model(model, 'path_to_saved_model')</code></p>
  
  <p>Which is experimental and creates multiple files :(.</p></li>
  <li><p><code>model.save('path_to_my_model.h5')</code></p>
  
  <p>Which saves h5 format :(.</p></li>
  <li><p><code>tf.saved_model.save(self.model, "test_x_model")</code></p>
  
  <p>Which agains save multiple files :(.</p></li>
  </ul>