Properly serialize ResourceVariable global_step into the metagraph.
authorEugene Brevdo <ebrevdo@google.com>
Wed, 28 Mar 2018 17:25:27 +0000 (10:25 -0700)
committerTensorFlower Gardener <gardener@tensorflow.org>
Wed, 28 Mar 2018 17:27:28 +0000 (10:27 -0700)
Prior to this, saving and restoring a graph with a resource variable global_step
would cause the global_step collection of the reimported graph to contain
a resource tensor (the object underlying the ResourceVariable); the actual
metadata associated with it would be serialized.

PiperOrigin-RevId: 190791443

tensorflow/python/ops/resource_variable_ops.py

index df873da..2f39ea2 100644 (file)
@@ -1087,6 +1087,11 @@ ops.register_proto_function(
     proto_type=variable_pb2.VariableDef,
     to_proto=_to_proto_fn,
     from_proto=_from_proto_fn)
+ops.register_proto_function(
+    ops.GraphKeys.GLOBAL_STEP,
+    proto_type=variable_pb2.VariableDef,
+    to_proto=_to_proto_fn,
+    from_proto=_from_proto_fn)
 
 
 def is_resource_variable(var):