diff --git a/tensorflow/python/ops/resource_variable_ops.py b/tensorflow/python/ops/resource_variable_ops.py index 5c74dffb055..f9faa3e945c 100644 --- a/tensorflow/python/ops/resource_variable_ops.py +++ b/tensorflow/python/ops/resource_variable_ops.py @@ -1433,7 +1433,7 @@ def _from_proto_fn(v, import_scope=None): """Creates Variable or ResourceVariable from VariableDef as needed.""" if v.is_resource: return ResourceVariable.from_proto(v, import_scope=import_scope) - return variables.Variable.from_proto(v, import_scope=import_scope) + return variables.RefVariable.from_proto(v, import_scope=import_scope) ops.register_proto_function( diff --git a/tensorflow/python/ops/variables.py b/tensorflow/python/ops/variables.py index f72b19bcdde..a001374e9ad 100644 --- a/tensorflow/python/ops/variables.py +++ b/tensorflow/python/ops/variables.py @@ -968,8 +968,7 @@ class Variable(six.with_metaclass(VariableMetaclass, @staticmethod def from_proto(variable_def, import_scope=None): """Returns a `Variable` object created from `variable_def`.""" - return RefVariable(variable_def=variable_def, - import_scope=import_scope) + raise NotImplementedError class SaveSliceInfo(object): """Information on how to save this Variable as a slice. @@ -2344,6 +2343,12 @@ class RefVariable(VariableV1): else: return None + @staticmethod + def from_proto(variable_def, import_scope=None): + """Returns a `Variable` object created from `variable_def`.""" + return RefVariable(variable_def=variable_def, + import_scope=import_scope) + def __iadd__(self, other): logging.log_first_n( logging.WARN,