MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / report_uninitialized_resources

Function report_uninitialized_resources

tensorflow/python/ops/resources.py:70–104  ·  view source on GitHub ↗

Returns the names of all uninitialized resources in resource_list. If the returned tensor is empty then all resources have been initialized. Args: resource_list: resources to check. If None, will use shared_resources() + local_resources(). name: name for the resource-checking op.

(resource_list=None,
                                   name="report_uninitialized_resources")

Source from the content-addressed store, hash-verified

68
69
70def report_uninitialized_resources(resource_list=None,
71 name="report_uninitialized_resources"):
72 """Returns the names of all uninitialized resources in resource_list.
73
74 If the returned tensor is empty then all resources have been initialized.
75
76 Args:
77 resource_list: resources to check. If None, will use shared_resources() +
78 local_resources().
79 name: name for the resource-checking op.
80
81 Returns:
82 Tensor containing names of the handles of all resources which have not
83 yet been initialized.
84
85 """
86 if resource_list is None:
87 resource_list = shared_resources() + local_resources()
88 with ops.name_scope(name):
89 # Run all operations on CPU
90 local_device = os.environ.get(
91 "TF_DEVICE_FOR_UNINITIALIZED_VARIABLE_REPORTING", "/cpu:0")
92 with ops.device(local_device):
93 if not resource_list:
94 # Return an empty tensor so we only need to check for returned tensor
95 # size being 0 as an indication of model ready.
96 return array_ops.constant([], dtype=dtypes.string)
97 # Get a 1-D boolean tensor listing whether each resource is initialized.
98 variables_mask = math_ops.logical_not(
99 array_ops.stack([r.is_initialized for r in resource_list]))
100 # Get a 1-D string tensor containing all the resource names.
101 variable_names_tensor = array_ops.constant(
102 [s.handle.name for s in resource_list])
103 # Return a 1-D tensor containing all the names of uninitialized resources.
104 return array_ops.boolean_mask(variable_names_tensor, variables_mask)
105
106
107@tf_should_use.should_use_result

Callers

nothing calls this directly

Calls 7

shared_resourcesFunction · 0.85
local_resourcesFunction · 0.85
name_scopeMethod · 0.45
getMethod · 0.45
deviceMethod · 0.45
constantMethod · 0.45
stackMethod · 0.45

Tested by

no test coverage detected