title: How to save a tensorflow graph without initialise a variable?
body: <p>The problem I encountered can be reflected as follow:</p>
  
  <pre><code>tf.reset_default_graph()
  
  x = tf.placeholder(dtype=tf.int32, shape=())
  init = tf.zeros(shape=tf.squeeze(x), dtype=tf.float32)
  
  v = tf.get_variable('foo', initializer=init, validate_shape=False)
  
  
  v_sig = tf.saved_model.signature_def_utils.build_signature_def(
              inputs={"x_input": tf.saved_model.utils.build_tensor_info(x)},
              outputs={
                  'v_output': tf.saved_model.utils.build_tensor_info(v)
              },
              method_name=tf.saved_model.signature_constants.PREDICT_METHOD_NAME
  )
  
  with tf.Session() as sess:
      builder = tf.saved_model.builder.SavedModelBuilder(export_dir="~/test/")
      sess.run(tf.global_variables_initializer())  # here leads to problem
      builder.add_meta_graph_and_variables(
          sess, [tf.saved_model.tag_constants.SERVING],
          signature_def_map={
              'v_sig': v_sig
          },
          main_op=tf.tables_initializer(),
          strip_default_attrs=True
      )
      builder.save()
  </code></pre>
  
  <p>I have a variable <code>foo</code> whose shape is calculated on the fly(depending on the input of placeholder <code>x</code>). When I tried to save it as a graph, I met error:</p>
  
  <blockquote>
    <p>You must feed a value for placeholder tensor 'Placeholder' with dtype int32</p>
  </blockquote>
  
  <p>If I don't run <code>global_variables_initializer</code>, it would has error <code>variable does not exists</code>.</p>
  
  <p>So how to resolve the situation? I have been stuck on this for quite some time, appreciate for an answer.</p>