list(ys) + list(xs) + list(stop_gradients) + list(grad_ys)) as grad_scope:
ys = ops.convert_n_to_tensor_or_indexed_slices(ys, name="y")
xs = [
- x.handle if isinstance(x, resource_variable_ops.ResourceVariable) else x
+ x.handle if resource_variable_ops.is_resource_variable(x) else x
for x in xs
]
xs = ops.internal_convert_n_to_tensor_or_indexed_slices(
proto_type=variable_pb2.VariableDef,
to_proto=_to_proto_fn,
from_proto=_from_proto_fn)
+
+
+def is_resource_variable(var):
+ """"Returns True if `var` is to be considered a ResourceVariable."""
+ return isinstance(var, ResourceVariable) or hasattr(
+ var, "_should_act_as_resource_variable")
from tensorflow.python.ops import variables
-def _is_resource(v):
- """Returns true if v is something you get from a resource variable."""
- return isinstance(v, resource_variable_ops.ResourceVariable)
-
-
def _create_slot_var(primary, val, scope, validate_shape, shape, dtype):
"""Helper function for creating a slot variable."""
shape = shape if callable(val) else None
slot = variable_scope.get_variable(
scope, initializer=val, trainable=False,
- use_resource=_is_resource(primary),
+ use_resource=resource_variable_ops.is_resource_variable(primary),
shape=shape, dtype=dtype,
validate_shape=validate_shape)
variable_scope.get_variable_scope().set_partitioner(current_partitioner)