id
stringlengths
15
25
source
stringclasses
1 value
chunk_index
int64
0
393k
token_count
int32
449
512
text
stringlengths
203
7.95k
combine_chunk_391700
combine.txt
391,700
512
_stats.node_name == "_SINK": continue yield profiling.ProfileDatum( device_step_stats.device, node_stats, node_to_file_path.get(node_stats.node_name, ""), node_to_line_number.get(node_stats.node_name, 0), node_to_func_name.get(node_stats.node...
combine_chunk_391701
combine.txt
391,701
512
column_widths = [ len(column_name) for column_name in profile_data.column_names()] for col in range(len(device_total_row)): column_widths[col] = max(column_widths[col], len(device_total_row[col])) for col in range(len(column_widths)): for row in range(profile_data.row_count()): colu...
combine_chunk_391702
combine.txt
391,702
512
def _measure_list_profile_column_widths(self, profile_data): """Determine the maximum column widths for each data list. Args: profile_data: list of ProfileDatum objects. Returns: List of column widths in the same order as columns in data. """ num_columns = len(profile_data.column_name...
combine_chunk_391703
combine.txt
391,703
512
.device_name_filter), " --%s: %s" % (_NODE_NAME_FILTER_FLAG, parsed.node_name_filter), " --%s: %s" % (_OP_TYPE_FILTER_FLAG, parsed.op_type_filter)]) max_total_cost = 0 for line_index in source_annotation: total_cost = self._get_total_cost(source_annotation[line_index], ...
combine_chunk_391704
combine.txt
391,704
512
_str( self._get_total_cost(annotation, parsed.cost_type), force_time_unit=parsed.time_unit), font_attr=self._LINE_COST_ATTR) total_cost += " " * (column_widths["total_cost"] - len(total_cost)) annotated_line += total_cost file_path_filter = re.esc...
combine_chunk_391705
combine.txt
391,705
512
(self, cost, max_cost, length): """Render a text bar representing a normalized cost. Args: cost: the absolute value of the cost. max_cost: the maximum cost value to normalize the absolute cost with. length: (int) length of the cost bar, in number of characters, excluding the brackets ...
combine_chunk_391706
combine.txt
391,706
512
"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRAN...
combine_chunk_391707
combine.txt
391,707
512
def set_help_intro(self, help_intro): """Set an introductory message to the help output of the command registry. Args: help_intro: (RichTextLines) Rich text lines appended to the beginning of the output of the command "help", as introductory information. """ self._command_handler_regis...
combine_chunk_391708
combine.txt
391,708
512
) The command arguments (i.e., not including the prefix). output_file_path: (str or None) The path to save the screen output to (if any). """ command = command.strip() if not command: return "", [], None command_items = command_parser.parse_command(command) command_items...
combine_chunk_391709
combine.txt
391,709
512
parsed = self._config_argparser.parse_args(args) if hasattr(parsed, "property_name") and hasattr(parsed, "property_value"): # set. self._config.set(parsed.property_name, parsed.property_value) return self._config.summarize(highlight=parsed.property_name) else: # show. return se...
combine_chunk_391710
combine.txt
391,710
512
CLI: See the doc of base_ui.BaseUI.run_ui for more details.""" print(title) if init_command is not None: self._dispatch_command(init_command) exit_token = self._ui_loop() if self._on_ui_exit: self._on_ui_exit() return exit_token def _ui_loop(self): while True: command ...
combine_chunk_391711
combine.txt
391,711
512
# You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the Li...
combine_chunk_391712
combine.txt
391,712
512
Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distrib...
combine_chunk_391713
combine.txt
391,713
512
.hooks import LocalCLIDebugHook from tensorflow.python.debug.wrappers.hooks import TensorBoardDebugHook from tensorflow.python.debug.wrappers.local_cli_wrapper import LocalCLIDebugWrapperSession from tensorflow.python.util import all_util as _all_util _all_util.remove_undocumented(__name__) <|file|>tensorflow/tenso...
combine_chunk_391714
combine.txt
391,714
512
_scope = base.keras_style_scope set_keras_style = base.set_keras_style Layer = base.Layer <|file|>tensorflow/tensorflow/python/layers/normalization.py # Copyright 2015 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in ...
combine_chunk_391715
combine.txt
391,715
512
d Conv2D = convolutional.Conv2D conv2d = convolutional.conv2d Conv3D = convolutional.Conv3D conv3d = convolutional.conv3d SeparableConv1D = convolutional.SeparableConv1D SeparableConv2D = convolutional.SeparableConv2D separable_conv1d = convolutional.separable_conv1d separable_conv2d = convolutional.separable_conv2d Co...
combine_chunk_391716
combine.txt
391,716
512
unused-import # Base objects. from tensorflow.python.layers.base import Layer # Core layers. from tensorflow.python.layers.core import Dense from tensorflow.python.layers.core import Dropout from tensorflow.python.layers.core import Flatten from tensorflow.python.layers.core import dense from tensorflow.python.layer...
combine_chunk_391717
combine.txt
391,717
512
ensorflow/python/layers/core.py # Copyright 2015 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2....
combine_chunk_391718
combine.txt
391,718
512
channels_first': if ndim == 3: return 'NCW' elif ndim == 4: return 'NCHW' elif ndim == 5: return 'NCDHW' else: raise ValueError(f'Input rank: {ndim} not supported. We only support ' 'input rank 3, 4 or 5.') else: raise ValueError(f'Invalid data_format...
combine_chunk_391719
combine.txt
391,719
512
', 'same'}: raise ValueError('The `padding` argument must be one of "valid", "same". ' f'Received: {str(padding)}.') return padding def conv_output_length(input_length, filter_size, padding, stride, dilation=1): """Determines output length of a convolution given input length. Args: ...
combine_chunk_391720
combine.txt
391,720
512
_size - stride, 0) elif padding == 'full': input_length -= (stride + filter_size - 2) return input_length def smart_cond(pred, true_fn=None, false_fn=None, name=None): """Return either `true_fn()` if predicate `pred` is true else `false_fn()`. If `pred` is a bool or has a constant value, we return either...
combine_chunk_391721
combine.txt
391,721
512
License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific languag...
combine_chunk_391722
combine.txt
391,722
512
the local name to use in the Checkpoint. Needed for migrating certain Trackables (see next paragraph) from the legacy `_gather_saveables_for_checkpoint` to the new `_serialize_to_tensors` function. This decorator should be used if the SaveableObject generates tensors with different names from the name that...
combine_chunk_391723
combine.txt
391,723
512
# TODO(kathywu): Add definite date for flag removal. global _FORCE_CHECKPOINT_CONVERSION _FORCE_CHECKPOINT_CONVERSION = value def force_checkpoint_conversion_enabled(): return _FORCE_CHECKPOINT_CONVERSION class CheckpointConversionError(Exception): pass <|file|>tensorflow/tensorflow/python/checkpoint/chec...
combine_chunk_391724
combine.txt
391,724
512
experimental_sharding_callback=None ): """Creates an object that stores options for a Checkpoint. Args: experimental_io_device: string. Applies in a distributed setting. Tensorflow device to use to access the filesystem. If `None` (default) then for each variable the filesystem is...
combine_chunk_391725
combine.txt
391,725
512
SizePolicy`. You may also write a custom callback, see `tf.train.experimental.ShardingCallback`. """ self.experimental_io_device = experimental_io_device self.enable_async = experimental_enable_async_checkpoint or enable_async self.experimental_enable_async_checkpoint = self.enable_async # E...
combine_chunk_391726
combine.txt
391,726
512
.module import module from tensorflow.python.ops import lookup_ops from tensorflow.python.ops import variables class TableModule(module.Module): """Three vars (one in a sub-module) and compute method.""" def __init__(self): default_value = -1 empty_key = 0 deleted_key = -1 self.lookup_table = loo...
combine_chunk_391727
combine.txt
391,727
512
The tensors are extracted from `Trackable._serialize_to_tensors`. """ import collections from typing import Any, Callable, List, Optional, Tuple, Mapping, Union, Dict from tensorflow.core.protobuf import trackable_object_graph_pb2 from tensorflow.python.checkpoint import graph_view as graph_view_lib from tensorflow.p...
combine_chunk_391728
combine.txt
391,728
512
.get_registered_saver_name(td.object_to_save) if isinstance(td.object_to_save, python_state.PythonState): pystate_trackables.append(td) elif saver_name: registered_trackables[saver_name].append(td) else: tensor_trackables.append(td) return tensor_trackables, pystate_trackables, register...
combine_chunk_391729
combine.txt
391,729
512
_get_and_write_tensors_to_serialize( tensor_trackables: List[_TrackableData], node_ids: Dict[base.Trackable, int], call_with_mapped_captures: Union[Callable[..., Any], None], cache: Union[Dict[base.Trackable, any], None], object_graph_proto: trackable_object_graph_pb2.TrackableObjectGraph ) -> Dict...
combine_chunk_391730
combine.txt
391,730
512
the # proto. object_names = object_identity.ObjectIdentityDictionary() object_names[trackable_data.trackable] = trackable_data.object_name object_map = object_identity.ObjectIdentityDictionary() object_map[trackable_data.trackable] = trackable_data.object_to_save checkpoint_factory_map, _ = save_util_v1.g...
combine_chunk_391731
combine.txt
391,731
512
return tensor_dict def _get_and_write_pystate_feed_additions( pystate_trackables: List[_TrackableData], cache: Union[Dict[base.Trackable, Any], None], object_graph_proto=None ) -> Tuple[Dict[base.Trackable, Any], Dict[base.Trackable, Any]]: """Gets feed additions needed for checkpointing Python State....
combine_chunk_391732
combine.txt
391,732
512
, cache: Optional[Dict[base.Trackable, Any]] = None, ): """Gathers serialization objects, and creates a TrackableObjectGraph proto.""" # There are 3 types of checkpoint serialization types supported: # 1. Trackables that override `Trackable._serialize_to_tensor()`. # 2. PythonState: A special type of Tracka...
combine_chunk_391733
combine.txt
391,733
512
Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # ...
combine_chunk_391734
combine.txt
391,734
512
- name: 'leaf', node_id: 4 - name: 'root', node_id: 0 - name: 'save_counter', node_id: 5 """ def __init__(self, save_path): """Configure the checkpoint view. Args: save_path: The path to the checkpoint. Raises: ValueError: If the save_path does not lead to a TF2 checkpoint. ""...
combine_chunk_391735
combine.txt
391,735
512
path = all_nodes_with_paths.get(node_id) if child.node_id not in all_nodes_with_paths.keys(): to_visit.append(child.node_id) all_nodes_with_paths[child.node_id] = path + "." + child.local_name return all_nodes_with_paths def match(self, obj): """Returns all matching trackab...
combine_chunk_391736
combine.txt
391,736
512
=float32, numpy=1.0>, <tf.Variable 'Variable:0' shape=() dtype=float32, numpy=2.0>])) (6, <tf.Variable 'Variable:0' shape=() dtype=float32, numpy=1.0>) (7, <tf.Variable 'Variable:0' shape=() dtype=float32, numpy=2.0>) """ if not isinstance(obj, base.Trackable): raise ValueError(f"Expected a T...
combine_chunk_391737
combine.txt
391,737
512
which were not restored. Example Usage: >>> class SimpleModule(tf.Module): ... def __init__(self, name=None): ... super().__init__(name=name) ... self.a_var = tf.Variable(5.0) ... self.b_var = tf.Variable(4.0) ... self.vars = [tf.Variable(1.0), tf.Variable(2.0)] >>>...
combine_chunk_391738
combine.txt
391,738
512
9, 10, 11, 12, 13, 14] >>> only_in_trackable = checkpoint_view_diff[2] >>> print(only_in_trackable) [..., <tf.Variable 'Variable:0' shape=() dtype=float32, numpy=5.0>, <tf.Variable 'Variable:0' shape=() dtype=float32, numpy=4.0>, ListWrapper([<tf.Variable 'Variable:0' shape=() dtype=float32, numpy=...
combine_chunk_391739
combine.txt
391,739
512
.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License....
combine_chunk_391740
combine.txt
391,740
512
options: Optional `CheckpointOptions` object. Returns: An `Operation`, or None when executing eagerly. """ options = options or checkpoint_options.CheckpointOptions() tensor_names = [] tensors = [] slice_specs = [] for checkpoint_key, tensor_slices in shard.items(): for slice_spec, tensor in te...
combine_chunk_391741
combine.txt
391,741
512
_tensor.checkpoint_key, shardable_tensor.slice_spec tensor_names.append(name) slice_specs.append(spec) tensor_dtypes.append(shardable_tensor.dtype) restore_device = options.experimental_io_device or "cpu:0" with ops.device(restore_device): restored_tensors = io_ops.restore_v2( file_prefix, ...
combine_chunk_391742
combine.txt
391,742
512
_with_replaced_captures def _get_mapped_registered_restore_fn( fn: Callable[..., tensor_lib.Tensor], trackables: Sequence[base.Trackable], call_with_mapped_captures: MappedCapturesCallable ) -> Callable[..., tensor_lib.Tensor]: """Converts the function to a python or tf.function with a single file arg."...
combine_chunk_391743
combine.txt
391,743
512
checkpoint. call_with_mapped_captures: TODO """ self._shardable_tensors_by_task: MutableMapping[ device_lib.DeviceSpec, MutableSequence[sharding_util.ShardableTensor]] = {} # Keep these two data structures so that we can map restored tensors to # the Trackable restore functions. ...
combine_chunk_391744
combine.txt
391,744
512
Tensor( _tensor_save_spec=tensor_save_spec, tensor=tensor_value, dtype=tensor_save_spec.dtype, device=device, name=tensor_save_spec.name, shape=None, slice_spec=slice_spec.strip(), ...
combine_chunk_391745
combine.txt
391,745
512
),), autograph=False) def _traced_save(self, file_prefix: tensor_lib.Tensor) -> tensor_lib.Tensor: save_op = self.save(file_prefix) with ops.device("cpu:0"): with ops.control_dependencies([save_op]): return array_ops.identity(file_prefix) @def_function.function( input_signature=(t...
combine_chunk_391746
combine.txt
391,746
512
dataclasses.replace( shardable_tensor, tensor=tensor_val, shape=tensor_shape) shardable_tensors_by_task = { task: [shardable_tensor for shardable_tensor in map(wrap_tensor, shardable_tensors) if shardable_tensor is not None] for task, sha...
combine_chunk_391747
combine.txt
391,747
512
# # <train dir>/ # myckpt{.index, .data-?????-of-?????} # # Filesystems with eventual consistency (such as S3), don't need a # temporary location. Using a temporary directory in those cases might # cause situations where files are not available during copy. # # Users...
combine_chunk_391748
combine.txt
391,748
512
for task, shards in shards_by_task: for shard in shards: with ops.device(task): shard_prefix = sharded_filename(tmp_checkpoint_prefix, shard_idx, num_shards_tensor) shard_idx += 1 saved_prefixes.append(shard_prefix) ...
combine_chunk_391749
combine.txt
391,749
512
, ops.Operation]: restore_fn_inputs = {} restore_fn_input_count = { fn: len(keys) for fn, keys in self._restore_fn_to_keys.items()} restore_ops = {} for task, shard in self._shardable_tensors_by_task.items(): with ops.device(task): # Load values from checkpoint ...
combine_chunk_391750
combine.txt
391,750
512
_device_saver = False for sts in self._shardable_tensors_by_task.values(): if any([context.is_custom_device(st.device.to_string()) for st in sts]): has_custom_device_saver = True break # Since this will cause a function re-trace on each restore, limit this to # cases where it is needed...
combine_chunk_391751
combine.txt
391,751
512
point import checkpoint_options from tensorflow.python.eager import context from tensorflow.python.framework import errors from tensorflow.python.framework import ops from tensorflow.python.lib.io import file_io from tensorflow.python.ops import variable_scope from tensorflow.python.platform import tf_logging as loggin...
combine_chunk_391752
combine.txt
391,752
512
Raises: ValueError: If `all_model_checkpoint_timestamps` was provided but its length does not match `all_model_checkpoint_paths`. """ if all_model_checkpoint_paths is None: all_model_checkpoint_paths = [] if (not all_model_checkpoint_paths or all_model_checkpoint_paths[-1] != model_checkpoi...
combine_chunk_391753
combine.txt
391,753
512
element must be equal to model_checkpoint_path. These paths are also saved in the CheckpointState proto. latest_filename: Optional name of the checkpoint file. Default to 'checkpoint'. all_model_checkpoint_timestamps: Optional list of timestamps (floats, seconds since the Epoch) indicating ...
combine_chunk_391754
combine.txt
391,754
512
e.g. due to a `keep_checkpoint_every_n_hours` parameter (see `tf.train.CheckpointManager` for an implementation). Raises: RuntimeError: If any of the model checkpoint paths conflict with the file containing CheckpointSate. """ # Writes the "checkpoint" file for the coordinator for later re...
combine_chunk_391755
combine.txt
391,755
512
isinstance(checkpoint_dir, os.PathLike): checkpoint_dir = os.fspath(checkpoint_dir) ckpt = None coord_checkpoint_filename = _GetCheckpointFilename(checkpoint_dir, latest_filename) f = None try: # Check that the file exists before opening it to avoid ...
combine_chunk_391756
combine.txt
391,756
512
def latest_checkpoint(checkpoint_dir, latest_filename=None): """Finds the filename of latest saved checkpoint file. Gets the checkpoint state given the provided checkpoint_dir and looks for a corresponding TensorFlow 2 (preferred) or TensorFlow 1.x checkpoint path. The latest_filename argument is only applicab...
combine_chunk_391757
combine.txt
391,757
512
) if file_io.get_matching_files(pathname): return True elif file_io.get_matching_files(checkpoint_prefix): return True else: return False @deprecation.deprecated( date=None, instructions="Use standard file APIs to check for files with this prefix.") @tf_export(v1=["train.checkpoint_exists"])...
combine_chunk_391758
combine.txt
391,758
512
0]).mtime_nsec / 1e9) return True return False for checkpoint_prefix in checkpoint_prefixes: # Tries V2's metadata file first. pathname = _prefix_to_checkpoint_path(checkpoint_prefix, saver_pb2.SaverDef.V2) if match_maybe_append(pathname): continu...
combine_chunk_391759
combine.txt
391,759
512
` file. Defaults to 'meta'. Returns: MetaGraph file name. """ # If the checkpoint_filename is sharded, the checkpoint_filename could # be of format model.ckpt-step#-?????-of-shard#. For example, # model.ckpt-123456-?????-of-00005, or model.ckpt-123456-00001-of-00002. basename = re.sub(r"-[\d\?]+-of-\d+...
combine_chunk_391760
combine.txt
391,760
512
CheckpointManager` instantiated in `directory` (regardless of the new setting of `keep_checkpoint_every_n_hours`). The `max_to_keep` checkpoints in the active set may be deleted by this `CheckpointManager` or a future `CheckpointManager` instantiated in `directory` (subject to its `max_to_keep` and ...
combine_chunk_391761
combine.txt
391,761
512
`tf.Variable` instance for checking the current step counter value, in case users want to save checkpoints every N steps. It should be passed if `checkpoint_interval` is not None. checkpoint_interval: An integer, indicates the minimum step interval between two checkpoints. init_fn: ...
combine_chunk_391762
combine.txt
391,762
512
that # old checkpoints don't get deleted accidentally. logging.warning( ("time.time() returned a value %f seconds behind the last " "preserved checkpoint timestamp.") % (self._last_preserved_timestamp - current_clock,)) self._last_preserved_timestamp = curre...
combine_chunk_391763
combine.txt
391,763
512
>= self._last_preserved_timestamp)): self._last_preserved_timestamp = timestamp continue _delete_file_if_exists(filename + ".index") _delete_file_if_exists(filename + ".data-?????-of-?????") def _record_state(self): """Saves the `CheckpointManager`'s state in `directory...
combine_chunk_391764
combine.txt
391,764
512
` object. This argument only works with TF2 checkpoint objects. For example, options = tf.saved_model.SaveOptions(experimental_io_device='/job:localhost') Returns: The path to the new checkpoint. It is also recorded in the `checkpoints` and `latest_checkpoint` properties. `None` if no c...
combine_chunk_391765
combine.txt
391,765
512
up old files, # but a preemption while deleting will be more likely to see the new # checkpoint this way. self._record_state() self._sweep() # Write out the Checkpoint proto a second time, now without the deleted # checkpoints. self._record_state() # Register `_record_and...
combine_chunk_391766
combine.txt
391,766
512
.restore(self._latest_checkpoint) if self._checkpoint_interval is not None: self._last_checkpoint_step = _evaluate(self._step_counter) return self._latest_checkpoint if self._init_fn is not None: self._init_fn() logging.info( "Customized initialization is done through the ...
combine_chunk_391767
combine.txt
391,767
512
a_var', <tf.Variable 'Variable:0' shape=() dtype=float32, numpy=5.0>) ('b_var', <tf.Variable 'Variable:0' shape=() dtype=float32, numpy=4.0>) ('vars', ListWrapper([<tf.Variable 'Variable:0' shape=() dtype=float32, numpy=1.0>, <tf.Variable 'Variable:0' shape=() dtype=float32, numpy=2.0>])) ('leaf', ...) """ ...
combine_chunk_391768
combine.txt
391,768
512
traversal.""" bfs_sorted = [] to_visit = collections.deque([self.root]) node_paths = object_identity.ObjectIdentityDictionary() node_paths[self.root] = () while to_visit: current_trackable = to_visit.popleft() bfs_sorted.append(current_trackable) for name, dependency in self.child...
combine_chunk_391769
combine.txt
391,769
512
"""Gathers and serializes an object graph.""" def __init__(self, root, attached_dependencies=None): """Configure the graph view. Args: root: A `Trackable` object whose variables (including the variables of dependencies, recursively) should be saved. May be a weak reference. attached_dep...
combine_chunk_391770
combine.txt
391,770
512
**kwargs: kwargs to use when retrieving the object's children. Returns: List of all children attached to the object. """ children = [] for name, ref in super(ObjectGraphView, self).children(obj, save_type, **kwargs).items(): children.append(base.TrackableRef...
combine_chunk_391771
combine.txt
391,771
512
based on a shortest path to the variable being slotted for, a shortest path to their optimizer, and the slot name. Args: saveables_cache: An optional cache storing previously created SaveableObjects created for each Trackable. Maps Trackables to a dictionary of attribute names to Trackab...
combine_chunk_391772
combine.txt
391,772
512
.python.checkpoint import checkpoint_management from tensorflow.python.checkpoint import checkpoint_options from tensorflow.python.checkpoint import functional_saver from tensorflow.python.checkpoint import graph_view as graph_view_lib from tensorflow.python.checkpoint import restore as restore_lib from tensorflow.pyth...
combine_chunk_391773
combine.txt
391,773
512
end_time_seconds < start_time_seconds: # Avoid returning negative value in case of clock skew. return 0 return round((end_time_seconds - start_time_seconds) * 1000000) @tf_export("__internal__.tracking.register_session_provider", v1=[]) def register_session_provider(session_provider): global _SESSION_PRO...
combine_chunk_391774
combine.txt
391,774
512
azily creates a mapping from node id to ("path", "to", "root").""" if self._node_name_cache is not None: return self._node_name_cache path_to_root = {} path_to_root[0] = ("(root)",) to_visit = collections.deque([0]) while to_visit: node_id = to_visit.popleft() obj = self._object_gr...
combine_chunk_391775
combine.txt
391,775
512
_checkpoint.append(pretty_printer.node_names[node_id]) for node_id, attribute_name in self.unused_attributes.items(): unrestored_attributes_in_object.append(( pretty_printer.node_names[node_id], attribute_name)) if unused_nodes_in_checkpoint or unrestored_attributes_in_object: # pylint:dis...
combine_chunk_391776
combine.txt
391,776
512
. """ self.options = options self.object_graph_proto = object_graph_proto self.restore_uid = ops.uid() # Maps from proto ids to lists of attributes which were in the checkpoint # but not loaded into any object, for error checking. self.unused_attributes = {} # Dictionary mapping from an ...
combine_chunk_391777
combine.txt
391,777
512
_attr = False if not self.options.experimental_skip_slot_variables: for node_index, node in enumerate(self.object_graph_proto.nodes): for slot_reference in node.slot_variables: # `node` refers to an `Optimizer`, since only these have slot # variables. self.slot_restoratio...
combine_chunk_391778
combine.txt
391,778
512
registered_savers: flat_saveables = saveable_object_util.validate_and_slice_inputs( tensor_saveables) new_restore_ops = functional_saver.MultiDeviceSaver.from_saveables( flat_saveables, registered_savers).restore(self.save_path_tensor, self.options) if not context.execut...
combine_chunk_391779
combine.txt
391,779
512
=False) for name, op in names_to_saveables.items(): for saveable_object in saveable_object_util.saveable_objects_for_op( op=op, name=name): yield saveable_object def eager_restore(self, trackable): """Runs restore ops for `trackable`'s attributes.""" # When graph building,...
combine_chunk_391780
combine.txt
391,780
512
_dtype if initializing_from_value: if shape is not None: raise ValueError("If initializer is a constant, do not specify shape.") initial_value = initializer else: # Instantiate initializer if provided initializer is a type object. if isinstance(initializer, type(init_ops.Initiali...
combine_chunk_391781
combine.txt
391,781
512
}\". Likely it was created with the " "TF1 name-based saver and does not contain an object dependency graph.") object_graph_proto = (trackable_object_graph_pb2.TrackableObjectGraph()) object_graph_proto.ParseFromString(object_graph_string) return object_graph_proto def list_objects(root_trackable): ""...
combine_chunk_391782
combine.txt
391,782
512
def _trackable_custom_creator(next_creator, name, initial_value, trackable_parent=None, **kwargs): """A variable creation hook which adds Trackable dependencies. Set for example dur...
combine_chunk_391783
combine.txt
391,783
512
_renaming_initializer, # Disable error checking for Trackable. Exceptions are instead # raised if necessary when the object-based saver tries to # save/restore the object. overwrite=True, trackable_parent=(template, name_prefix), **kwargs) el...
combine_chunk_391784
combine.txt
391,784
512
As a workaround, consider either using tf.train.Checkpoint to " "load name-based checkpoints or enabling eager execution.") status.run_restore_ops(session=session) # pylint: disable=protected-access status._checkpoint.new_restore_ops_callback = ( lambda ops: session.run(ops, feed_dict=status._feed_...
combine_chunk_391785
combine.txt
391,785
512
_ids = [] if self._options.experimental_skip_slot_variables: for node in self._checkpoint.object_graph_proto.nodes: for sv in node.slot_variables: ignore_node_ids.append(sv.slot_variable_node_id) for node_id, node in enumerate(self._checkpoint.object_graph_proto.nodes): if not node...
combine_chunk_391786
combine.txt
391,786
512
): trackable = self._checkpoint.object_by_proto_id.get(node_id, None) if (trackable is not None and trackable._update_uid < self._checkpoint.restore_uid): # pylint: disable=protected-access raise AssertionError( f"Object {node} not assigned a value from checkpoint.") for t...
combine_chunk_391787
combine.txt
391,787
512
program. The following objects have no matching " f"checkpointed value: {list(unused_python_objects)}" ) else: raise AssertionError( "Nothing to load. No dependencies have been added to " f"{self._object_graph_view.root} yet." ) return self def r...
combine_chunk_391788
combine.txt
391,788
512
and will initialize variables in `InitializationOnlyStatus` objects or restore them otherwise. """ def __init__(self, object_graph_view, restore_uid): self._restore_uid = restore_uid self._object_graph_view = object_graph_view # Keep a reference to the root, since graph_view might only have a weak...
combine_chunk_391789
combine.txt
391,789
512
a name-based tf.train.Saver checkpoint using the object-based " "restore API. This mode uses global names to match variables, and so is " "somewhat fragile. It also adds new restore ops to the graph each time it " "is called when graph building. Prefer re-encoding training checkpoints in " "the object-...
combine_chunk_391790
combine.txt
391,790
512
_initialize_trackable() if trackable._update_uid < self._checkpoint.restore_uid: raise AssertionError(f"Object not restored: {trackable}") # pylint: enable=protected-access return self def assert_existing_objects_matched(self): """Raises an exception if currently created objects are unmat...
combine_chunk_391791
combine.txt
391,791
512
def __init__(self, session, feed_additions): self._wrapped_session = session self._feed_additions = feed_additions def run(self, fetches, feed_dict=None, **kwargs): if feed_dict is None: feed_dict = {} else: feed_dict = feed_dict.copy() feed_dict.update(self._feed_additions) retu...
combine_chunk_391792
combine.txt
391,792
512
IdentityWeakKeyDictionary() self._saveables_cache = object_identity.ObjectIdentityWeakKeyDictionary() # The file prefix placeholder is created lazily when graph building (and not # at all when executing eagerly) to avoid creating ops in the constructor # (when they may never be necessary). self._...
combine_chunk_391793
combine.txt
391,793
512
feed when running it (if graph building). The feed dict contains the current object graph and any Python state to be saved in the checkpoint. When executing eagerly only the first argument is meaningful. """ serialized_tensors, feed_additions, registered_savers, graph_proto = ( self._g...
combine_chunk_391794
combine.txt
391,794
512
_eagerly() and not ops.inside_function()) if checkpoint_number: file_prefix = "%s-%d" % (file_prefix, checkpoint_number) if use_session: if self._object_graph_feed_tensor is None: with ops.device("/cpu:0"): self._object_graph_feed_tensor = constant_op.constant( ...
combine_chunk_391795
combine.txt
391,795
512
. The assert will raise an exception unless every object was matched and all checkpointed values have a matching variable object. ```python saver = Saver(root) saver.restore(path).assert_consumed() ``` When graph building, `assert_consumed()` indicates that all of the restore ops whic...
combine_chunk_391796
combine.txt
391,796
512
(chienchunh): Allow to load the file while other checkpoint events # are still ongiing. Need to add timeout mechanism along # with conditional variables to notify when the checkpoint # file is ready. global _ASYNC_CHECKPOINT_THREAD if _ASYNC_CHEC...
combine_chunk_391797
combine.txt
391,797
512
graph_view.root, reader) # Attached dependencies are not attached to the root, so should be restored # separately. if self._graph_view.attached_dependencies: for ref in self._graph_view.attached_dependencies: if ref.name == "root": ...
combine_chunk_391798
combine.txt
391,798
512
functional_saver.MultiDeviceSaver.from_saveables( named_saveable_objects, registered_savers) def _assert_trackable(obj, name): if not isinstance( obj, (base.Trackable, def_function.Function)): raise ValueError( f"`Checkpoint` was expecting {name} to be a trackable object (an " f"obj...
combine_chunk_391799
combine.txt
391,799
512
implementations. It saves these values with a checkpoint, and maintains a `save_counter` for numbering checkpoints. Example usage when graph building: ```python import tensorflow as tf import os checkpoint_directory = "/tmp/training_checkpoints" checkpoint_prefix = os.path.join(checkpoint_directory, "...