tensorflow_serving/servables/tensorflow/testdata/export_counter.py
def export_model(output_dir):
  """Exports the counter model.

  Create three signatures: incr_counter, incr_counter_by, reset_counter.

  *Notes*: These signatures are stateful and over-simplied only to demonstrate
  Predict calls with only inputs or outputs. State is not supported in
  TensorFlow Serving on most scalable or production hosting environments.

  Args:
    output_dir: string, output directory for the model.
  """
  tf.logging.info("Exporting the counter model to %s.", output_dir)
  method_name = tf.saved_model.signature_constants.PREDICT_METHOD_NAME

  graph = tf.Graph()
  with graph.as_default(), tf.Session() as sess:
    counter = tf.Variable(0.0, dtype=tf.float32, name="counter")

    with tf.name_scope("incr_counter_op", values=[counter]):
      incr_counter = counter.assign_add(1.0)

    delta = tf.placeholder(dtype=tf.float32, name="delta")
    with tf.name_scope("incr_counter_by_op", values=[counter, delta]):
      incr_counter_by = counter.assign_add(delta)

    with tf.name_scope("reset_counter_op", values=[counter]):
      reset_counter = counter.assign(0.0)

    sess.run(tf.global_variables_initializer())

    signature_def_map = {
        "get_counter":
            build_signature_def_from_tensors({}, {"output": counter},
                                             method_name),
        "incr_counter":
            build_signature_def_from_tensors({}, {"output": incr_counter},
                                             method_name),
        "incr_counter_by":
            build_signature_def_from_tensors({
                "delta": delta
            }, {"output": incr_counter_by}, method_name),
        "reset_counter":
            build_signature_def_from_tensors({}, {"output": reset_counter},
                                             method_name)
    }
    save_model(sess, signature_def_map, output_dir)
Exports the counter model.

  Create three signatures: incr_counter, incr_counter_by, reset_counter.

  *Notes*: These signatures are stateful and over-simplied only to demonstrate
  Predict calls with only inputs or outputs. State is not supported in
  TensorFlow Serving on most scalable or production hosting environments.

  Args:
    output_dir: string, output directory for the model.
  
Exports the counter model.

Notes*: These signatures are stateful and over-simplied only to demonstrate
Predict calls with only inputs or outputs. State is not supported in
TensorFlow Serving on most scalable or production hosting environments.
Exports the counter model . Notes * : These signatures are stateful and over - simplied only to demonstrate Predict calls with only inputs or outputs . State is not supported in TensorFlow Serving on most scalable or production hosting environments .
def export_model(output_dir):
  tf.logging.info("Exporting the counter model to %s.", output_dir)
  method_name = tf.saved_model.signature_constants.PREDICT_METHOD_NAME
  graph = tf.Graph()
  with graph.as_default(), tf.Session() as sess:
    counter = tf.Variable(0.0, dtype=tf.float32, name="counter")
    with tf.name_scope("incr_counter_op", values=[counter]):
      incr_counter = counter.assign_add(1.0)
    delta = tf.placeholder(dtype=tf.float32, name="delta")
    with tf.name_scope("incr_counter_by_op", values=[counter, delta]):
      incr_counter_by = counter.assign_add(delta)
    with tf.name_scope("reset_counter_op", values=[counter]):
      reset_counter = counter.assign(0.0)
    sess.run(tf.global_variables_initializer())
    signature_def_map = {
        "get_counter":
            build_signature_def_from_tensors({}, {"output": counter},
                                             method_name),
        "incr_counter":
            build_signature_def_from_tensors({}, {"output": incr_counter},
                                             method_name),
        "incr_counter_by":
            build_signature_def_from_tensors({
                "delta": delta
            }, {"output": incr_counter_by}, method_name),
        "reset_counter":
            build_signature_def_from_tensors({}, {"output": reset_counter},
                                             method_name)
    }
    save_model(sess, signature_def_map, output_dir)
def export_model ( output_dir ) : tf . logging . info ( "Exporting the counter model to %s." , output_dir ) method_name = tf . saved_model . signature_constants . PREDICT_METHOD_NAME graph = tf . Graph ( ) with graph . as_default ( ) , tf . Session ( ) as sess : counter = tf . Variable ( 0.0 , dtype = tf . float32 , name = "counter" ) with tf . name_scope ( "incr_counter_op" , values = [ counter ] ) : incr_counter = counter . assign_add ( 1.0 ) delta = tf . placeholder ( dtype = tf . float32 , name = "delta" ) with tf . name_scope ( "incr_counter_by_op" , values = [ counter , delta ] ) : incr_counter_by = counter . assign_add ( delta ) with tf . name_scope ( "reset_counter_op" , values = [ counter ] ) : reset_counter = counter . assign ( 0.0 ) sess . run ( tf . global_variables_initializer ( ) ) signature_def_map = { "get_counter" : build_signature_def_from_tensors ( { } , { "output" : counter } , method_name ) , "incr_counter" : build_signature_def_from_tensors ( { } , { "output" : incr_counter } , method_name ) , "incr_counter_by" : build_signature_def_from_tensors ( { "delta" : delta } , { "output" : incr_counter_by } , method_name ) , "reset_counter" : build_signature_def_from_tensors ( { } , { "output" : reset_counter } , method_name ) } save_model ( sess , signature_def_map , output_dir )
Exports the counter model.
Exports the counter model .
"""Exports the counter model.

  Create three signatures: incr_counter, incr_counter_by, reset_counter.

  *Notes*: These signatures are stateful and over-simplied only to demonstrate
  Predict calls with only inputs or outputs. State is not supported in
  TensorFlow Serving on most scalable or production hosting environments.

  Args:
    output_dir: string, output directory for the model.
  """
output_dir
string, output directory for the model.
string output directory for the model .