signature
stringlengths
8
3.44k
body
stringlengths
0
1.41M
docstring
stringlengths
1
122k
id
stringlengths
5
17
def event_count(self, event_key):
return self._trackers[event_key].event_count<EOL>
Obtain event count. Args: event_key: the type key of the sought events (e.g., constants.NAN_KEY). If None, includes all event type keys. Returns: If event_key is None, return the sum of the event_count of all event types. Otherwise, return the event_count of the...
f7941:c1:m4
def create_jsonable_history(self):
return {value_category_key: tracker.get_description()<EOL>for (value_category_key, tracker) in self._trackers.items()}<EOL>
Creates a JSON-able representation of this object. Returns: A dictionary mapping key to EventTrackerDescription (which can be used to create event trackers).
f7941:c1:m5
def __init__(self, capacity=<NUM_LIT:100>, initialization_list=None):
self._capacity = capacity<EOL>self._data = dict()<EOL>if initialization_list:<EOL><INDENT>for entry in initialization_list:<EOL><INDENT>triplet = HistoryTriplet._make(entry)<EOL>self._data[(triplet.device, triplet.tensor)] = NumericsAlertHistory(<EOL>initialization_list=triplet.jsonable_history)<EOL><DEDENT><DEDENT>
Constructor. Args: capacity: (`int`) maximum number of device-tensor keys to store. initialization_list: (`list`) An optional list (parsed from JSON) that is used to initialize the data within this registry. Use the create_jsonable_registry method of NumericsAlertReg...
f7941:c2:m0
def register(self, numerics_alert):
key = (numerics_alert.device_name, numerics_alert.tensor_name)<EOL>if key in self._data:<EOL><INDENT>self._data[key].add(numerics_alert)<EOL><DEDENT>else:<EOL><INDENT>if len(self._data) < self._capacity:<EOL><INDENT>history = NumericsAlertHistory()<EOL>history.add(numerics_alert)<EOL>self._data[key] = history<EOL><DEDE...
Register an alerting numeric event. Args: numerics_alert: An instance of `NumericsAlert`.
f7941:c2:m1
def report(self, device_name_filter=None, tensor_name_filter=None):
report = []<EOL>for key in self._data:<EOL><INDENT>device_name, tensor_name = key<EOL>history = self._data[key]<EOL>report.append(<EOL>NumericsAlertReportRow(<EOL>device_name=device_name,<EOL>tensor_name=tensor_name,<EOL>first_timestamp=history.first_timestamp(),<EOL>nan_event_count=history.event_count(constants.NAN_KE...
Get a report of offending device/tensor names. The report includes information about the device name, tensor name, first (earliest) timestamp of the alerting events from the tensor, in addition to counts of nan, positive inf and negative inf events. Args: device_name_filter: ...
f7941:c2:m2
def create_jsonable_registry(self):
<EOL>return [HistoryTriplet(pair[<NUM_LIT:0>], pair[<NUM_LIT:1>], history.create_jsonable_history())<EOL>for (pair, history) in self._data.items()]<EOL>
Creates a JSON-able representation of this object. Returns: A dictionary mapping (device, tensor name) to JSON-able object representations of NumericsAlertHistory.
f7941:c2:m3
def __init__(self,<EOL>watch_key,<EOL>mem_bytes_limit=<NUM_LIT>):
self._watch_key = watch_key<EOL>self._mem_bytes_limit = mem_bytes_limit<EOL>self._in_mem_bytes = <NUM_LIT:0><EOL>self._disposed = False<EOL>self._data = []<EOL>
Constructor of _WatchStore. The overflowing works as follows: The most recent tensor values are stored in memory, up to `mem_bytes_limit` bytes. But at least one (the most recent) value is always stored in memory. For older tensors exceeding that limit, they are discarded. Args...
f7942:c1:m0
def add(self, value):
if self._disposed:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>')<EOL><DEDENT>self._data.append(value)<EOL>if hasattr(value, '<STR_LIT>'):<EOL><INDENT>self._in_mem_bytes += value.nbytes<EOL>self._ensure_bytes_limits()<EOL><DEDENT>
Add a tensor the watch store.
f7942:c1:m1
def num_total(self):
return len(self._data)<EOL>
Get the total number of values.
f7942:c1:m3
def num_in_memory(self):
n = len(self._data) - <NUM_LIT:1><EOL>while n >= <NUM_LIT:0>:<EOL><INDENT>if isinstance(self._data[n], _TensorValueDiscarded):<EOL><INDENT>break<EOL><DEDENT>n -= <NUM_LIT:1><EOL><DEDENT>return len(self._data) - <NUM_LIT:1> - n<EOL>
Get number of values in memory.
f7942:c1:m4
def num_discarded(self):
if not self._data:<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT>n = <NUM_LIT:0><EOL>while n < len(self._data):<EOL><INDENT>if not isinstance(self._data[n], _TensorValueDiscarded):<EOL><INDENT>break<EOL><DEDENT>n += <NUM_LIT:1><EOL><DEDENT>return n<EOL>
Get the number of values discarded due to exceeding both limits.
f7942:c1:m5
def query(self, time_indices):
if self._disposed:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>')<EOL><DEDENT>if not isinstance(time_indices, (tuple, list)):<EOL><INDENT>time_indices = [time_indices]<EOL><DEDENT>output = []<EOL>for time_index in time_indices:<EOL><INDENT>if isinstance(self._data[time_index], _TensorValueDiscarded):<EOL><INDENT>output...
Query the values at given time indices. Args: time_indices: 0-based time indices to query, as a `list` of `int`. Returns: Values as a list of `numpy.ndarray` (for time indices in memory) or `None` (for time indices discarded).
f7942:c1:m6
def __init__(self, watch_mem_bytes_limit=<NUM_LIT>):
self._watch_mem_bytes_limit = watch_mem_bytes_limit<EOL>self._tensor_data = dict()<EOL>
Constructor of TensorStore. Args: watch_mem_bytes_limit: Limit on number of bytes to store in memory for each watch key.
f7942:c2:m0
def add(self, watch_key, tensor_value):
if watch_key not in self._tensor_data:<EOL><INDENT>self._tensor_data[watch_key] = _WatchStore(<EOL>watch_key,<EOL>mem_bytes_limit=self._watch_mem_bytes_limit)<EOL><DEDENT>self._tensor_data[watch_key].add(tensor_value)<EOL>
Add a tensor value. Args: watch_key: A string representing the debugger tensor watch, e.g., 'Dense_1/BiasAdd:0:DebugIdentity'. tensor_value: The value of the tensor as a numpy.ndarray.
f7942:c2:m1
def query(self,<EOL>watch_key,<EOL>time_indices=None,<EOL>slicing=None,<EOL>mapping=None):
if watch_key not in self._tensor_data:<EOL><INDENT>raise KeyError("<STR_LIT>" % watch_key)<EOL><DEDENT>if time_indices is None:<EOL><INDENT>time_indices = '<STR_LIT>'<EOL><DEDENT>time_slicing = tensor_helper.parse_time_indices(time_indices)<EOL>all_time_indices = list(range(self._tensor_data[watch_key].num_total()))<EO...
Query tensor store for a given watch_key. Args: watch_key: The watch key to query. time_indices: A numpy-style slicing string for time indices. E.g., `-1`, `:-2`, `[::2]`. If not provided (`None`), will use -1. slicing: A numpy-style slicing string for individual time ...
f7942:c2:m2
def get_gated_grpc_tensors(self, matching_debug_op=None):
with self._grpc_gated_lock:<EOL><INDENT>matching_debug_op = matching_debug_op or '<STR_LIT>'<EOL>if matching_debug_op not in self._grpc_gated_tensors:<EOL><INDENT>node_name_to_op_type = dict(<EOL>(node.name, node.op) for node in self._graph_def.node)<EOL>gated = []<EOL>for node in self._graph_def.node:<EOL><INDENT>if n...
Extract all nodes with gated-gRPC debug ops attached. Uses cached values if available. This method is thread-safe. Args: graph_def: A tf.GraphDef proto. matching_debug_op: Return tensors and nodes with only matching the specified debug op name (optional). If `No...
f7943:c0:m1
def maybe_base_expanded_node_name(self, node_name):
with self._node_name_lock:<EOL><INDENT>if self._maybe_base_expanded_node_names is None:<EOL><INDENT>self._maybe_base_expanded_node_names = dict()<EOL>sorted_names = sorted(node.name for node in self._graph_def.node)<EOL>for i, name in enumerate(sorted_names):<EOL><INDENT>j = i + <NUM_LIT:1><EOL>while j < len(sorted_nam...
Expand the base name if there are node names nested under the node. For example, if there are two nodes in the graph, "a" and "a/read", then calling this function on "a" will give "a/(a)", a form that points at a leaf node in the nested TensorBoard graph. Calling this function on "a/rea...
f7943:c0:m2
def _serverGet(self, path, params=None, expected_status_code=<NUM_LIT:200>):
url = _SERVER_URL_PREFIX + path<EOL>if params:<EOL><INDENT>url += '<STR_LIT:?>' + urllib.parse.urlencode(params)<EOL><DEDENT>response = self._server.get(url)<EOL>self.assertEqual(expected_status_code, response.status_code)<EOL>return response<EOL>
Send the serve a GET request and obtain the response. Args: path: URL path (excluding the prefix), without parameters encoded. params: Query parameters to be encoded in the URL, as a dict. expected_status_code: Expected status code. Returns: Response from server...
f7946:c0:m2
def _deserializeResponse(self, response):
return json.loads(response.get_data().decode("<STR_LIT:utf-8>"))<EOL>
Deserializes byte content that is a JSON encoding. Args: response: A response object. Returns: The deserialized python object decoded from JSON.
f7946:c0:m3
def _CreateEventWithDebugNumericSummary(<EOL>self, device_name, op_name, output_slot, wall_time, step, list_of_values):
event = tf.compat.v1.Event(step=step, wall_time=wall_time)<EOL>tensor = tf.compat.v1.make_tensor_proto(<EOL>list_of_values, dtype=tf.float64, shape=[len(list_of_values)])<EOL>value = event.summary.value.add(<EOL>tag=op_name,<EOL>node_name='<STR_LIT>' % (op_name, output_slot),<EOL>tensor=tensor)<EOL>content_proto = debu...
Creates event with a health pill summary. Note the debugger plugin only works with TensorFlow and, thus, uses TF protos and TF EventsWriter. Args: device_name: The name of the op's device. op_name: The name of the op to which a DebugNumericSummary was attached. ou...
f7947:c0:m3
def _DeserializeResponse(self, byte_content):
return json.loads(byte_content.decode('<STR_LIT:utf-8>'))<EOL>
Deserializes byte content that is a JSON encoding. Args: byte_content: The byte content of a JSON response. Returns: The deserialized python object decoded from JSON.
f7947:c0:m4
def define_flags(self, parser):
group = parser.add_argument_group('<STR_LIT>')<EOL>group.add_argument(<EOL>'<STR_LIT>',<EOL>metavar='<STR_LIT>',<EOL>type=int,<EOL>default=-<NUM_LIT:1>,<EOL>help='''<STR_LIT>'''at which the interactive debugger data server (to be started by<EOL>gger plugin) should receive debugging data via gRPC from one or<EOL>ugger-e...
Adds DebuggerPlugin CLI flags to parser.
f7949:c0:m0
def fix_flags(self, flags):
<EOL>if flags.debugger_data_server_grpc_port > <NUM_LIT:0> and flags.debugger_port > <NUM_LIT:0>:<EOL><INDENT>raise base_plugin.FlagsError(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>
Fixes Debugger related flags. Raises: ValueError: If both the `debugger_data_server_grpc_port` and `debugger_port` flags are specified as >= 0.
f7949:c0:m1
def load(self, context):
if not (context.flags.debugger_data_server_grpc_port > <NUM_LIT:0> or<EOL>context.flags.debugger_port > <NUM_LIT:0>):<EOL><INDENT>return None<EOL><DEDENT>flags = context.flags<EOL>try:<EOL><INDENT>import tensorflow<EOL><DEDENT>except ImportError:<EOL><INDENT>raise ImportError(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDE...
Returns the debugger plugin, if possible. Args: context: The TBContext flags including `add_arguments`. Returns: A DebuggerPlugin instance or None if it couldn't be loaded.
f7949:c0:m2
def __init__(self,<EOL>events_directory,<EOL>single_file_size_cap_bytes=_DEFAULT_EVENTS_FILE_SIZE_CAP_BYTES,<EOL>check_this_often=_DEFAULT_CHECK_EVENT_FILES_SIZE_CAP_EVERY,<EOL>total_file_size_cap_bytes=_DEFAULT_TOTAL_SIZE_CAP_BYTES,<EOL>always_flush=False):
self._events_directory = events_directory<EOL>self._single_file_size_cap_bytes = single_file_size_cap_bytes<EOL>self.total_file_size_cap_bytes = total_file_size_cap_bytes<EOL>self._check_this_often = check_this_often<EOL>self._always_flush = always_flush<EOL>self._events_file_count = <NUM_LIT:0><EOL>events_file_names =...
Constructs an EventsWriterManager. Args: events_directory: (`string`) The log directory in which debugger events reside. single_file_size_cap_bytes: (`int`) A number of bytes. During a check, if the manager determines that the events file being written to exceeds ...
f7950:c0:m0
def write_event(self, event):
self._lock.acquire()<EOL>try:<EOL><INDENT>self._events_writer.WriteEvent(event)<EOL>self._event_count += <NUM_LIT:1><EOL>if self._always_flush:<EOL><INDENT>self._events_writer.Flush()<EOL><DEDENT>if self._event_count == self._check_this_often:<EOL><INDENT>self._event_count = <NUM_LIT:0><EOL>self._events_writer.Flush()<...
Writes an event proto to disk. This method is threadsafe with respect to invocations of itself. Args: event: The event proto. Raises: IOError: If writing the event proto to disk fails.
f7950:c0:m1
def get_current_file_name(self):
return tf.compat.as_text(self._events_writer.FileName())<EOL>
Gets the name of the events file currently being written to. Returns: The name of the events file being written to.
f7950:c0:m2
def dispose(self):
self._lock.acquire()<EOL>self._events_writer.Close()<EOL>self._events_writer = None<EOL>self._lock.release()<EOL>
Disposes of this events writer manager, making it no longer usable. Call this method when this object is done being used in order to clean up resources and handlers. This method should ever only be called once.
f7950:c0:m3
def _create_events_writer(self, directory):
total_size = <NUM_LIT:0><EOL>events_files = self._fetch_events_files_on_disk()<EOL>for file_name in events_files:<EOL><INDENT>file_path = os.path.join(self._events_directory, file_name)<EOL>total_size += tf.io.gfile.stat(file_path).length<EOL><DEDENT>if total_size >= self.total_file_size_cap_bytes:<EOL><INDENT>for file...
Creates a new events writer. Args: directory: The directory in which to write files containing events. Returns: A new events writer, which corresponds to a new events file.
f7950:c0:m4
def _fetch_events_files_on_disk(self):
all_files = tf.io.gfile.listdir(self._events_directory)<EOL>relevant_files = [<EOL>file_name for file_name in all_files<EOL>if _DEBUGGER_EVENTS_FILE_NAME_REGEX.match(file_name)<EOL>]<EOL>return sorted(relevant_files, key=self._obtain_file_index)<EOL>
Obtains the names of debugger-related events files within the directory. Returns: The names of the debugger-related events files written to disk. The names are sorted in increasing events file index.
f7950:c0:m5
def _obtain_file_index(self, file_name):
return int(_DEBUGGER_EVENTS_FILE_NAME_REGEX.match(file_name).group(<NUM_LIT:1>))<EOL>
Obtains the file index associated with an events file. The index is stored within a file name and is incremented every time a new events file is created. Assumes that the file name is a valid debugger events file name. Args: file_name: The name of the debugger-related events ...
f7950:c0:m6
def put(self, message):
with self._outgoing_lock:<EOL><INDENT>self._outgoing.append(message)<EOL>self._outgoing_counter += <NUM_LIT:1><EOL>if self._outgoing_counter in self._outgoing_pending_queues:<EOL><INDENT>for q in self._outgoing_pending_queues[self._outgoing_counter]:<EOL><INDENT>q.put(message)<EOL><DEDENT>del self._outgoing_pending_que...
Put a message into the outgoing message stack. Outgoing message will be stored indefinitely to support multi-users.
f7952:c0:m1
def get(self, pos):
if pos <= <NUM_LIT:0>:<EOL><INDENT>raise ValueError('<STR_LIT>' % pos)<EOL><DEDENT>with self._outgoing_lock:<EOL><INDENT>if self._outgoing_counter >= pos:<EOL><INDENT>return self._outgoing[pos - <NUM_LIT:1>], self._outgoing_counter<EOL><DEDENT>else:<EOL><INDENT>if pos not in self._outgoing_pending_queues:<EOL><INDENT>s...
Get message(s) from the outgoing message stack. Blocks until an item at stack position pos becomes available. This method is thread safe. Args: pos: An int specifying the top position of the message stack to access. For example, if the stack counter is at 3 and pos == 2...
f7952:c0:m2
def __init__(self, context):
self._event_multiplexer = context.multiplexer<EOL>self._logdir = context.logdir<EOL>self._debugger_data_server = None<EOL>self._grpc_port = None<EOL>
Constructs a debugger plugin for TensorBoard. This plugin adds handlers for retrieving debugger-related data. The plugin also starts a debugger data server once the log directory is passed to the plugin via the call to get_plugin_apps. Args: context: A base_plugin.TBContext i...
f7955:c0:m0
def listen(self, grpc_port):
if self._grpc_port:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>" %<EOL>self._grpc_port)<EOL><DEDENT>self._grpc_port = grpc_port<EOL>sys.stderr.write('<STR_LIT>' %<EOL>(self._grpc_port, self._logdir))<EOL>sys.stderr.flush()<EOL>self._debugger_data_server = debugger_server_lib.DebuggerDataServer(<EOL>self._grpc_port, se...
Start listening on the given gRPC port. This method of an instance of DebuggerPlugin can be invoked at most once. This method is not thread safe. Args: grpc_port: port number to listen at. Raises: ValueError: If this instance is already listening at a gRPC port.
f7955:c0:m1
def get_plugin_apps(self):
return {<EOL>_HEALTH_PILLS_ROUTE: self._serve_health_pills_handler,<EOL>_NUMERICS_ALERT_REPORT_ROUTE: self._serve_numerics_alert_report_handler,<EOL>}<EOL>
Obtains a mapping between routes and handlers. This function also starts a debugger data server on separate thread if the plugin has not started one yet. Returns: A mapping between routes and handlers (functions that respond to requests).
f7955:c0:m2
def is_active(self):
return bool(<EOL>self._grpc_port is not None and<EOL>self._event_multiplexer and<EOL>self._event_multiplexer.PluginRunToTagToContent(<EOL>constants.DEBUGGER_PLUGIN_NAME))<EOL>
Determines whether this plugin is active. This plugin is active if any health pills information is present for any run. Returns: A boolean. Whether this plugin is active.
f7955:c0:m3
@wrappers.Request.application<EOL><INDENT>def _serve_health_pills_handler(self, request):<DEDENT>
if request.method != '<STR_LIT:POST>':<EOL><INDENT>return wrappers.Response(response=(<EOL>'<STR_LIT>' %<EOL>request.method), status=<NUM_LIT>)<EOL><DEDENT>if _NODE_NAMES_POST_KEY not in request.form:<EOL><INDENT>return wrappers.Response(response=(<EOL>'<STR_LIT>' %<EOL>_NODE_NAMES_POST_KEY), status=<NUM_LIT>)<EOL><DED...
A (wrapped) werkzeug handler for serving health pills. Accepts POST requests and responds with health pills. The request accepts several POST parameters: node_names: (required string) A JSON-ified list of node names for which the client would like to request health pills. ...
f7955:c0:m4
def _obtain_sampled_health_pills(self, run, node_names):
runs_to_tags_to_content = self._event_multiplexer.PluginRunToTagToContent(<EOL>constants.DEBUGGER_PLUGIN_NAME)<EOL>if run not in runs_to_tags_to_content:<EOL><INDENT>return {}<EOL><DEDENT>tags_to_content = runs_to_tags_to_content[run]<EOL>mapping = {}<EOL>for node_name in node_names:<EOL><INDENT>if node_name not in tag...
Obtains the health pills for a run sampled by the event multiplexer. This is much faster than the alternative path of reading health pills from disk. Args: run: The run to fetch health pills for. node_names: A list of node names for which to retrieve health pills. ...
f7955:c0:m5
def _tensor_proto_to_health_pill(self, tensor_event, node_name, device,<EOL>output_slot):
return self._process_health_pill_value(<EOL>wall_time=tensor_event.wall_time,<EOL>step=tensor_event.step,<EOL>device_name=device,<EOL>output_slot=output_slot,<EOL>node_name=node_name,<EOL>tensor_proto=tensor_event.tensor_proto)<EOL>
Converts an event_accumulator.TensorEvent to a HealthPillEvent. Args: tensor_event: The event_accumulator.TensorEvent to convert. node_name: The name of the node (without the output slot). device: The device. output_slot: The integer output slot this health pill is relev...
f7955:c0:m6
def _obtain_health_pills_at_step(self, events_directory, node_names, step):
<EOL>pattern = os.path.join(events_directory, _DEBUGGER_EVENTS_GLOB_PATTERN)<EOL>file_paths = glob.glob(pattern)<EOL>if not file_paths:<EOL><INDENT>raise IOError(<EOL>'<STR_LIT>' % pattern)<EOL><DEDENT>file_paths.sort()<EOL>mapping = collections.defaultdict(list)<EOL>node_name_set = frozenset(node_names)<EOL>for file_p...
Reads disk to obtain the health pills for a run at a specific step. This could be much slower than the alternative path of just returning all health pills sampled by the event multiplexer. It could take tens of minutes to complete this call for large graphs for big step values (in the t...
f7955:c0:m7
def _process_health_pill_event(self, node_name_set, mapping, target_step,<EOL>file_path):
events_loader = event_file_loader.EventFileLoader(file_path)<EOL>for event in events_loader.Load():<EOL><INDENT>if not event.HasField('<STR_LIT>'):<EOL><INDENT>logger.warn(<EOL>'<STR_LIT>')<EOL>continue<EOL><DEDENT>if event.step < target_step:<EOL><INDENT>continue<EOL><DEDENT>if event.step > target_step:<EOL><INDENT>re...
Creates health pills out of data in an event. Creates health pills out of the event and adds them to the mapping. Args: node_name_set: A set of node names that are relevant. mapping: The mapping from node name to HealthPillEvents. This object may be destructively modi...
f7955:c0:m8
def _process_health_pill_value(self,<EOL>wall_time,<EOL>step,<EOL>device_name,<EOL>output_slot,<EOL>node_name,<EOL>tensor_proto,<EOL>node_name_set=None):
if node_name_set and node_name not in node_name_set:<EOL><INDENT>return None<EOL><DEDENT>elements = list(tensor_util.make_ndarray(tensor_proto))<EOL>return HealthPillEvent(<EOL>wall_time=wall_time,<EOL>step=step,<EOL>device_name=device_name,<EOL>output_slot=output_slot,<EOL>node_name=node_name,<EOL>dtype=repr(tf.as_dty...
Creates a HealthPillEvent containing various properties of a health pill. Args: wall_time: The wall time in seconds. step: The session run step of the event. device_name: The name of the node's device. output_slot: The numeric output slot. node_name: The name o...
f7955:c0:m9
@wrappers.Request.application<EOL><INDENT>def _serve_numerics_alert_report_handler(self, request):<DEDENT>
if request.method != '<STR_LIT:GET>':<EOL><INDENT>logger.error(<EOL>'<STR_LIT>', request.method)<EOL>return wrappers.Response(status=<NUM_LIT>)<EOL><DEDENT>report = self._debugger_data_server.numerics_alert_report()<EOL>response = [r._asdict() for r in report] <EOL>return http_util.Respond(request, response, '<STR_LIT...
A (wrapped) werkzeug handler for serving numerics alert report. Accepts GET requests and responds with an array of JSON-ified NumericsAlertReportRow. Each JSON-ified NumericsAlertReportRow object has the following format: { 'device_name': string, 'tensor_name': ...
f7955:c0:m10
def __init__(self, context):
del context <EOL>self._debugger_data_server = None<EOL>self._server_thread = None<EOL>self._grpc_port = None<EOL>
Constructs a debugger plugin for TensorBoard. This plugin adds handlers for retrieving debugger-related data. The plugin also starts a debugger data server once the log directory is passed to the plugin via the call to get_plugin_apps. Args: context: A base_plugin.TBContext i...
f7956:c0:m0
def listen(self, grpc_port):
if self._grpc_port:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' % self._grpc_port)<EOL><DEDENT>self._grpc_port = grpc_port<EOL>sys.stderr.write('<STR_LIT>' %<EOL>self._grpc_port)<EOL>sys.stderr.flush()<EOL>self._debugger_data_server = (<EOL>interactive_debugger_server_lib.InteractiveDebuggerDataServer...
Start listening on the given gRPC port. This method of an instance of InteractiveDebuggerPlugin can be invoked at most once. This method is not thread safe. Args: grpc_port: port number to listen at. Raises: ValueError: If this instance is already listening at a gR...
f7956:c0:m1
def get_plugin_apps(self):
return {<EOL>_ACK_ROUTE: self._serve_ack,<EOL>_COMM_ROUTE: self._serve_comm,<EOL>_DEBUGGER_GRPC_HOST_PORT_ROUTE: self._serve_debugger_grpc_host_port,<EOL>_DEBUGGER_GRAPH_ROUTE: self._serve_debugger_graph,<EOL>_GATED_GRPC_ROUTE: self._serve_gated_grpc,<EOL>_TENSOR_DATA_ROUTE: self._serve_tensor_data,<EOL>_SOURCE_CODE_RO...
Obtains a mapping between routes and handlers. This function also starts a debugger data server on separate thread if the plugin has not started one yet. Returns: A mapping between routes and handlers (functions that respond to requests).
f7956:c0:m3
def is_active(self):
return self._grpc_port is not None<EOL>
Determines whether this plugin is active. This plugin is active if any health pills information is present for any run. Returns: A boolean. Whether this plugin is active.
f7956:c0:m4
def calc_health_pill(tensor):
health_pill = [<NUM_LIT:0.0>] * <NUM_LIT><EOL>if not isinstance(tensor, np.ndarray):<EOL><INDENT>return health_pill<EOL><DEDENT>health_pill[<NUM_LIT:0>] = <NUM_LIT:1.0><EOL>if not (np.issubdtype(tensor.dtype, np.float) or<EOL>np.issubdtype(tensor.dtype, np.complex) or<EOL>np.issubdtype(tensor.dtype, np.integer) or<EOL>...
Calculate health pill of a tensor. Args: tensor: An instance of `np.array` (for initialized tensors) or `tensorflow.python.debug.lib.debug_data.InconvertibleTensorProto` (for unininitialized tensors). Returns: If `tensor` is an initialized tensor of numeric or boolean types: ...
f7958:m0
def numel(shape):
output = <NUM_LIT:1><EOL>for dim in shape:<EOL><INDENT>output *= dim<EOL><DEDENT>return output<EOL>
Obtain total number of elements from a tensor (ndarray) shape. Args: shape: A list or tuple represenitng a tensor (ndarray) shape.
f7959:m0
def parse_time_indices(s):
if not s.startswith('<STR_LIT:[>'):<EOL><INDENT>s = '<STR_LIT:[>' + s + '<STR_LIT:]>'<EOL><DEDENT>parsed = command_parser._parse_slices(s)<EOL>if len(parsed) != <NUM_LIT:1>:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>' % len(parsed))<EOL><DEDENT>else:<EOL><INDENT>return parsed[<NUM_LIT:0>]<EOL><DEDENT>
Parse a string as time indices. Args: s: A valid slicing string for time indices. E.g., '-1', '[:]', ':', '2:10' Returns: A slice object. Raises: ValueError: If `s` does not represent valid time indices.
f7959:m1
def translate_dtype(dtype):
out = str(dtype)<EOL>return '<STR_LIT:string>' if out == '<STR_LIT:object>' else out<EOL>
Translate numpy dtype into a string. The 'object' type is understood as a TensorFlow string and translated into 'string'. Args: dtype: A numpy dtype object. Returns: A string representing the data type.
f7959:m2
def process_buffers_for_display(s, limit=<NUM_LIT>):
if isinstance(s, (list, tuple)):<EOL><INDENT>return [process_buffers_for_display(elem, limit=limit) for elem in s]<EOL><DEDENT>else:<EOL><INDENT>length = len(s)<EOL>if length > limit:<EOL><INDENT>return (binascii.b2a_qp(s[:limit]) +<EOL>b'<STR_LIT>' % (length, limit))<EOL><DEDENT>else:<EOL><INDENT>return binascii.b2a_q...
Process a buffer for human-readable display. This function performs the following operation on each of the buffers in `s`. 1. Truncate input buffer if the length of the buffer is greater than `limit`, to prevent large strings from overloading the frontend. 2. Apply `binascii.b2a_qp` on the tru...
f7959:m3
def array_view(array, slicing=None, mapping=None):
dtype = translate_dtype(array.dtype)<EOL>sliced_array = (array[command_parser._parse_slices(slicing)] if slicing<EOL>else array)<EOL>if np.isscalar(sliced_array) and str(dtype) == '<STR_LIT:string>':<EOL><INDENT>ndims = len(array.shape)<EOL>slice_shape = []<EOL>for _ in range(ndims):<EOL><INDENT>sliced_array = [sliced_...
View a slice or the entirety of an ndarray. Args: array: The input array, as an numpy.ndarray. slicing: Optional slicing string, e.g., "[:, 1:3, :]". mapping: Optional mapping string. Supported mappings: `None` or case-insensitive `'None'`: Unmapped nested list. `'image/png'`: Ima...
f7959:m4
def array_to_base64_png(array):
<EOL>array = np.array(array, dtype=np.float32)<EOL>if len(array.shape) != <NUM_LIT:2>:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>" % len(array.shape))<EOL><DEDENT>if not np.size(array):<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>" % (array.shape,))<EOL><DEDENT>is_infinity = np.isinf(array)<EOL>is_positive = array > ...
Convert an array into base64-enoded PNG image. Args: array: A 2D np.ndarray or nested list of items. Returns: A base64-encoded string the image. The image is grayscale if the array is 2D. The image is RGB color if the image is 3D with lsat dimension equal to 3. Raises: Value...
f7959:m5
def _extract_device_name_from_event(event):
plugin_data_content = json.loads(<EOL>tf.compat.as_str(event.summary.value[<NUM_LIT:0>].metadata.plugin_data.content))<EOL>return plugin_data_content['<STR_LIT>']<EOL>
Extract device name from a tf.Event proto carrying tensor value.
f7960:m0
def _comm_tensor_data(device_name,<EOL>node_name,<EOL>maybe_base_expanded_node_name,<EOL>output_slot,<EOL>debug_op,<EOL>tensor_value,<EOL>wall_time):
output_slot = int(output_slot)<EOL>logger.info(<EOL>'<STR_LIT>', node_name, output_slot, debug_op)<EOL>tensor_values = None<EOL>if isinstance(tensor_value, debug_data.InconvertibleTensorProto):<EOL><INDENT>if not tensor_value.initialized:<EOL><INDENT>tensor_dtype = UNINITIALIZED_TAG<EOL>tensor_shape = UNINITIALIZED_TAG...
Create a dict() as the outgoing data in the tensor data comm route. Note: The tensor data in the comm route does not include the value of the tensor in its entirety in general. Only if a tensor satisfies the following conditions will its entire value be included in the return value of this method: ...
f7960:m2
def __init__(self, breakpoints_func=None):
<EOL>self._run_key_to_original_graphs = dict()<EOL>self._run_key_to_debug_graphs = dict()<EOL>if breakpoints_func:<EOL><INDENT>assert callable(breakpoints_func)<EOL>self._breakpoints_func = breakpoints_func<EOL><DEDENT>
Constructor of RunStates. Args: breakpoint_func: A callable of the signatuer: def breakpoint_func(): which returns all the currently activated breakpoints.
f7960:c0:m0
def add_graph(self, run_key, device_name, graph_def, debug=False):
graph_dict = (self._run_key_to_debug_graphs if debug else<EOL>self._run_key_to_original_graphs)<EOL>if not run_key in graph_dict:<EOL><INDENT>graph_dict[run_key] = dict() <EOL><DEDENT>graph_dict[run_key][tf.compat.as_str(device_name)] = (<EOL>debug_graphs_helper.DebugGraphWrapper(graph_def))<EOL>
Add a GraphDef. Args: run_key: A key for the run, containing information about the feeds, fetches, and targets. device_name: The name of the device that the `GraphDef` is for. graph_def: An instance of the `GraphDef` proto. debug: Whether `graph_def` consists...
f7960:c0:m1
def get_graphs(self, run_key, debug=False):
graph_dict = (self._run_key_to_debug_graphs if debug else<EOL>self._run_key_to_original_graphs)<EOL>graph_wrappers = graph_dict.get(run_key, {})<EOL>graph_defs = dict()<EOL>for device_name, wrapper in graph_wrappers.items():<EOL><INDENT>graph_defs[device_name] = wrapper.graph_def<EOL><DEDENT>return graph_defs<EOL>
Get the runtime GraphDef protos associated with a run key. Args: run_key: A Session.run kay. debug: Whether the debugger-decoratedgraph is to be retrieved. Returns: A `dict` mapping device name to `GraphDef` protos.
f7960:c0:m2
def get_graph(self, run_key, device_name, debug=False):
return self.get_graphs(run_key, debug=debug).get(device_name, None)<EOL>
Get the runtime GraphDef proto associated with a run key and a device. Args: run_key: A Session.run kay. device_name: Name of the device in question. debug: Whether the debugger-decoratedgraph is to be retrieved. Returns: A `GraphDef` proto.
f7960:c0:m3
def get_breakpoints(self):
return self._breakpoints_func()<EOL>
Obtain all the currently activated breakpoints.
f7960:c0:m4
def get_maybe_base_expanded_node_name(self, node_name, run_key, device_name):
device_name = tf.compat.as_str(device_name)<EOL>if run_key not in self._run_key_to_original_graphs:<EOL><INDENT>raise ValueError('<STR_LIT>' % run_key)<EOL><DEDENT>if device_name not in self._run_key_to_original_graphs[run_key]:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>' % (run_key, device_name))<EOL><DEDENT>return ...
Obtain possibly base-expanded node name. Base-expansion is the transformation of a node name which happens to be the name scope of other nodes in the same graph. For example, if two nodes, called 'a/b' and 'a/b/read' in a graph, the name of the first node will be base-expanded to 'a/b/(...
f7960:c0:m6
def __init__(<EOL>self, incoming_channel, outgoing_channel, run_states, tensor_store):
super(InteractiveDebuggerDataStreamHandler, self).__init__()<EOL>self._incoming_channel = incoming_channel<EOL>self._outgoing_channel = outgoing_channel<EOL>self._run_states = run_states<EOL>self._tensor_store = tensor_store<EOL>self._run_key = None<EOL>self._graph_defs = dict() <EOL>self._graph_defs_arrive_first = Tr...
Constructor of InteractiveDebuggerDataStreamHandler. Args: incoming_channel: An instance of FIFO queue, which manages incoming data, e.g., ACK signals from the client side unblock breakpoints. outgoing_channel: An instance of `CommChannel`, which manages outgoing dat...
f7960:c1:m0
def on_core_metadata_event(self, event):
core_metadata = json.loads(event.log_message.message)<EOL>input_names = '<STR_LIT:U+002C>'.join(core_metadata['<STR_LIT>'])<EOL>output_names = '<STR_LIT:U+002C>'.join(core_metadata['<STR_LIT>'])<EOL>target_nodes = '<STR_LIT:U+002C>'.join(core_metadata['<STR_LIT>'])<EOL>self._run_key = RunKey(input_names, output_names, ...
Implementation of the core metadata-carrying Event proto callback. Args: event: An Event proto that contains core metadata about the debugged Session::Run() in its log_message.message field, as a JSON string. See the doc string of debug_data.DebugDumpDir.core_metadata for deta...
f7960:c1:m1
def on_graph_def(self, graph_def, device_name, wall_time):
<EOL>del wall_time<EOL>self._graph_defs[device_name] = graph_def<EOL>if not self._graph_defs_arrive_first:<EOL><INDENT>self._add_graph_def(device_name, graph_def)<EOL>self._incoming_channel.get()<EOL><DEDENT>
Implementation of the GraphDef-carrying Event proto callback. Args: graph_def: A GraphDef proto. N.B.: The GraphDef is from the core runtime of a debugged Session::Run() call, after graph partition. Therefore it may differ from the GraphDef available to the general...
f7960:c1:m3
def on_value_event(self, event):
if not event.summary.value:<EOL><INDENT>logger.info('<STR_LIT>')<EOL>return None<EOL><DEDENT>watch_key = event.summary.value[<NUM_LIT:0>].node_name<EOL>tensor_value = debug_data.load_tensor_from_event(event)<EOL>device_name = _extract_device_name_from_event(event)<EOL>node_name, output_slot, debug_op = (<EOL>event.summ...
Records the summary values based on an updated message from the debugger. Logs an error message if writing the event to disk fails. Args: event: The Event proto to be processed.
f7960:c1:m4
def add_debugged_source_file(self, debugged_source_file):
<EOL>key = debugged_source_file.file_path<EOL>self._source_file_host[key] = debugged_source_file.host<EOL>self._source_file_last_modified[key] = debugged_source_file.last_modified<EOL>self._source_file_bytes[key] = debugged_source_file.bytes<EOL>self._source_file_content[key] = debugged_source_file.lines<EOL>
Add a DebuggedSourceFile proto.
f7960:c2:m1
def get_paths(self):
return list(self._source_file_content.keys())<EOL>
Get the paths to all available source files.
f7960:c2:m3
def get_content(self, file_path):
return self._source_file_content[file_path]<EOL>
Get the content of a source file. # TODO(cais): Maybe support getting a range of lines by line number. Args: file_path: Path to the source file.
f7960:c2:m4
def get_op_traceback(self, op_name):
if not self._graph_traceback:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>for op_log_entry in self._graph_traceback.log_entries:<EOL><INDENT>if op_log_entry.name == op_name:<EOL><INDENT>return self._code_def_to_traceback_list(op_log_entry.code_def)<EOL><DEDENT><DEDENT>raise ValueError(<EOL>'<STR_LIT>'<EOL>'<S...
Get the traceback of an op in the latest version of the TF graph. Args: op_name: Name of the op. Returns: Creation traceback of the op, in the form of a list of 2-tuples: (file_path, lineno) Raises: ValueError: If the op with the given name cannot be ...
f7960:c2:m5
def get_file_tracebacks(self, file_path):
if file_path not in self._source_file_content:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' % file_path)<EOL><DEDENT>lineno_to_op_names_and_stack_position = dict()<EOL>for op_log_entry in self._graph_traceback.log_entries:<EOL><INDENT>for stack_pos, trace in enumerate(op_log_entry.code_def.traces):<EOL...
Get the lists of ops created at lines of a specified source file. Args: file_path: Path to the source file. Returns: A dict mapping line number to a list of 2-tuples, `(op_name, stack_position)` `op_name` is the name of the name of the op whose creation traceb...
f7960:c2:m6
def __init__(self, receive_port):
super(InteractiveDebuggerDataServer, self).__init__(<EOL>receive_port, InteractiveDebuggerDataStreamHandler)<EOL>self._incoming_channel = queue.Queue()<EOL>self._outgoing_channel = comm_channel_lib.CommChannel()<EOL>self._run_states = RunStates(breakpoints_func=lambda: self.breakpoints)<EOL>self._tensor_store = tensor_...
Receives health pills from a debugger and writes them to disk. Args: receive_port: The port at which to receive health pills from the TensorFlow debugger. always_flush: A boolean indicating whether the EventsWriter will be flushed after every write. Can be used for t...
f7960:c3:m0
def query_tensor_store(self,<EOL>watch_key,<EOL>time_indices=None,<EOL>slicing=None,<EOL>mapping=None):
return self._tensor_store.query(watch_key,<EOL>time_indices=time_indices,<EOL>slicing=slicing,<EOL>mapping=mapping)<EOL>
Query tensor store for a given debugged tensor value. Args: watch_key: The watch key of the debugged tensor being sought. Format: <node_name>:<output_slot>:<debug_op> E.g., Dense_1/MatMul:0:DebugIdentity. time_indices: Optional time indices string By default, the las...
f7960:c3:m8
def query_source_file_paths(self):
return self._source_manager.get_paths()<EOL>
Query the source files involved in the current debugged TF program. Returns: A `list` of file paths. The files that belong to the TensorFlow Python library itself are *not* included.
f7960:c3:m9
def query_source_file_content(self, file_path):
return list(self._source_manager.get_content(file_path))<EOL>
Query the content of a given source file. # TODO(cais): Allow query only a range of the source lines. Returns: The source lines as a list of `str`.
f7960:c3:m10
def query_op_traceback(self, op_name):
return self._source_manager.get_op_traceback(op_name)<EOL>
Query the tracebacks of ops in a TensorFlow graph. Returns: TODO(cais):
f7960:c3:m11
def query_file_tracebacks(self, file_path):
return self._source_manager.get_file_tracebacks(file_path)<EOL>
Query the lists of ops created at lines of a given source file. Args: file_path: Path to the source file to get the tracebacks for. Returns: A `dict` mapping line number in the specified source file to a list of 2-tuples: `(op_name, stack_position)`. ...
f7960:c3:m12
def dispose(self):
self._tensor_store.dispose()<EOL>
Disposes of this object. Call only after this is done being used.
f7960:c3:m13
def process_raw_trace(raw_trace):
trace = trace_events_pb2.Trace()<EOL>trace.ParseFromString(raw_trace)<EOL>return '<STR_LIT>'.join(trace_events_json.TraceEventsJsonStream(trace))<EOL>
Processes raw trace data and returns the UI data.
f7961:m0
def __init__(self, context):
self.logdir = context.logdir<EOL>self.multiplexer = context.multiplexer<EOL>self.plugin_logdir = plugin_asset_util.PluginDirectory(<EOL>self.logdir, PLUGIN_NAME)<EOL>self.stub = None<EOL>self.master_tpu_unsecure_channel = context.flags.master_tpu_unsecure_channel<EOL>self._is_active = False<EOL>self._is_active_lock = t...
Constructs a profiler plugin for TensorBoard. This plugin adds handlers for performance-related frontends. Args: context: A base_plugin.TBContext instance.
f7961:c0:m0
def is_active(self):
<EOL>if not self._is_active and self._is_active_lock.acquire(False):<EOL><INDENT>if self._is_active:<EOL><INDENT>self._is_active_lock.release()<EOL><DEDENT>else:<EOL><INDENT>def compute_is_active():<EOL><INDENT>self._is_active = any(self.generate_run_to_tools())<EOL>self._is_active_lock.release()<EOL><DEDENT>new_thread...
Whether this plugin is active and has any profile data to show. Detecting profile data is expensive, so this process runs asynchronously and the value reported by this method is the cached value and may be stale. Returns: Whether any run has profile data.
f7961:c0:m1
def _run_dir(self, run):
run = run.rstrip('<STR_LIT:/>')<EOL>if '<STR_LIT:/>' not in run:<EOL><INDENT>run = '<STR_LIT>' + run<EOL><DEDENT>tb_run_name, _, profile_run_name = run.rpartition('<STR_LIT:/>')<EOL>tb_run_directory = self.multiplexer.RunPaths().get(tb_run_name)<EOL>if tb_run_directory is None:<EOL><INDENT>if tb_run_name == '<STR_LIT:....
Helper that maps a frontend run name to a profile "run" directory. The frontend run name consists of the TensorBoard run name (aka the relative path from the logdir root to the directory containing the data) path-joined to the Profile plugin's "run" concept (which is a subdirectory of the ...
f7961:c0:m3
def generate_run_to_tools(self):
self.start_grpc_stub_if_necessary()<EOL>plugin_assets = self.multiplexer.PluginAssets(PLUGIN_NAME)<EOL>tb_run_names_to_dirs = self.multiplexer.RunPaths()<EOL>if '<STR_LIT:.>' not in plugin_assets and tf.io.gfile.isdir(self.logdir):<EOL><INDENT>tb_run_names_to_dirs['<STR_LIT:.>'] = self.logdir<EOL>plugin_assets['<STR_LI...
Generator for pairs of "run name" and a list of tools for that run. The "run name" here is a "frontend run name" - see _run_dir() for the definition of a "frontend run name" and how it maps to a directory of profile data for a specific profile "run". The profile plugin concept of "run" ...
f7961:c0:m4
def host_impl(self, run, tool):
hosts = {}<EOL>run_dir = self._run_dir(run)<EOL>if not run_dir:<EOL><INDENT>logger.warn("<STR_LIT>", run)<EOL>return hosts<EOL><DEDENT>tool_pattern = '<STR_LIT:*>' + TOOLS[tool]<EOL>try:<EOL><INDENT>files = tf.io.gfile.glob(os.path.join(run_dir, tool_pattern))<EOL>hosts = [os.path.basename(f).replace(TOOLS[tool], '<STR...
Returns available hosts for the run and tool in the log directory. In the plugin log directory, each directory contains profile data for a single run (identified by the directory name), and files in the run directory contains data for different tools and hosts. The file that contains pr...
f7961:c0:m7
def data_impl(self, request):
run = request.args.get('<STR_LIT>')<EOL>tool = request.args.get('<STR_LIT>')<EOL>host = request.args.get('<STR_LIT:host>')<EOL>run_dir = self._run_dir(run)<EOL>profile_run = os.path.basename(run_dir)<EOL>if tool not in TOOLS:<EOL><INDENT>return None<EOL><DEDENT>self.start_grpc_stub_if_necessary()<EOL>if tool == '<STR_L...
Retrieves and processes the tool data for a run and a host. Args: request: XMLHttpRequest Returns: A string that can be served to the frontend tool or None if tool, run or host is invalid.
f7961:c0:m9
def __init__(self, proto):
self._proto = proto<EOL>
Create an iterable JSON stream over the supplied Trace. Args: proto: a tensorboard.profile.Trace protobuf
f7962:c0:m0
def _events(self):
for did, device in sorted(six.iteritems(self._proto.devices)):<EOL><INDENT>if device.name:<EOL><INDENT>yield dict(<EOL>ph=_TYPE_METADATA,<EOL>pid=did,<EOL>name='<STR_LIT>',<EOL>args=dict(name=device.name))<EOL><DEDENT>yield dict(<EOL>ph=_TYPE_METADATA,<EOL>pid=did,<EOL>name='<STR_LIT>',<EOL>args=dict(sort_index=did))<E...
Iterator over all catapult trace events, as python values.
f7962:c0:m1
def _event(self, event):
result = dict(<EOL>pid=event.device_id,<EOL>tid=event.resource_id,<EOL>name=event.name,<EOL>ts=event.timestamp_ps / <NUM_LIT>)<EOL>if event.duration_ps:<EOL><INDENT>result['<STR_LIT>'] = _TYPE_COMPLETE<EOL>result['<STR_LIT>'] = event.duration_ps / <NUM_LIT><EOL><DEDENT>else:<EOL><INDENT>result['<STR_LIT>'] = _TYPE_INST...
Converts a TraceEvent proto into a catapult trace event python value.
f7962:c0:m2
def __iter__(self):
yield '<STR_LIT>'<EOL>yield '<STR_LIT>'<EOL>for event in self._events():<EOL><INDENT>yield json.dumps(event)<EOL>yield '<STR_LIT>'<EOL><DEDENT>yield '<STR_LIT>'<EOL>
Returns an iterator of string chunks of a complete JSON document.
f7962:c0:m3
def load(self, context):
try:<EOL><INDENT>import tensorflow<EOL>from tensorflow.python.eager import profiler_client<EOL><DEDENT>except ImportError:<EOL><INDENT>return<EOL><DEDENT>from tensorboard.plugins.profile.profile_plugin import ProfilePlugin<EOL>return ProfilePlugin(context)<EOL>
Returns the plugin, if possible. Args: context: The TBContext flags. Returns: A ProfilePlugin instance or None if it couldn't be loaded.
f7963:c0:m1
def dump_data(logdir):
<EOL>write_empty_event_file(logdir)<EOL>plugin_logdir = plugin_asset_util.PluginDirectory(<EOL>logdir, profile_plugin.ProfilePlugin.plugin_name)<EOL>_maybe_create_directory(plugin_logdir)<EOL>for run in profile_demo_data.RUNS:<EOL><INDENT>run_dir = os.path.join(plugin_logdir, run)<EOL>_maybe_create_directory(run_dir)<E...
Dumps plugin data to the log directory.
f7965:m2
def op(name,<EOL>data,<EOL>display_name=None,<EOL>description=None,<EOL>collections=None):
<EOL>import tensorflow.compat.v1 as tf<EOL>if display_name is None:<EOL><INDENT>display_name = name<EOL><DEDENT>summary_metadata = metadata.create_summary_metadata(<EOL>display_name=display_name, description=description)<EOL>with tf.name_scope(name):<EOL><INDENT>with tf.control_dependencies([tf.assert_scalar(data)]):<E...
Create a legacy scalar summary op. Arguments: name: A unique name for the generated summary node. data: A real numeric rank-0 `Tensor`. Must have `dtype` castable to `float32`. display_name: Optional name for this summary in TensorBoard, as a constant `str`. Defaults to `name`. ...
f7969:m0
def pb(name, data, display_name=None, description=None):
<EOL>import tensorflow.compat.v1 as tf<EOL>data = np.array(data)<EOL>if data.shape != ():<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>% data.shape)<EOL><DEDENT>if data.dtype.kind not in ('<STR_LIT:b>', '<STR_LIT:i>', '<STR_LIT:u>', '<STR_LIT:f>'): <EOL><INDENT>raise ValueError('<STR_LIT>' % data.dtype.name)<EOL><DEDE...
Create a legacy scalar summary protobuf. Arguments: name: A unique name for the generated summary, including any desired name scopes. data: A rank-0 `np.array` or array-like form (so raw `int`s and `float`s are fine, too). display_name: Optional name for this summary in TensorBoar...
f7969:m1
def run(logdir, run_name,<EOL>initial_temperature, ambient_temperature, heat_coefficient):
tf.compat.v1.reset_default_graph()<EOL>tf.compat.v1.set_random_seed(<NUM_LIT:0>)<EOL>with tf.name_scope('<STR_LIT>'):<EOL><INDENT>temperature = tf.Variable(tf.constant(initial_temperature),<EOL>name='<STR_LIT>')<EOL>summary.op('<STR_LIT>', temperature,<EOL>display_name='<STR_LIT>',<EOL>description='<STR_LIT>'<EOL>'<STR...
Run a temperature simulation. This will simulate an object at temperature `initial_temperature` sitting at rest in a large room at temperature `ambient_temperature`. The object has some intrinsic `heat_coefficient`, which indicates how much thermal conductivity it has: for instance, metals have high ...
f7970:m0
def run_all(logdir, verbose=False):
for initial_temperature in [<NUM_LIT>, <NUM_LIT>, <NUM_LIT>]:<EOL><INDENT>for final_temperature in [<NUM_LIT>, <NUM_LIT>, <NUM_LIT>]:<EOL><INDENT>for heat_coefficient in [<NUM_LIT>, <NUM_LIT>]:<EOL><INDENT>run_name = '<STR_LIT>' % (<EOL>initial_temperature, final_temperature, heat_coefficient)<EOL>if verbose:<EOL><INDE...
Run simulations on a reasonable set of parameters. Arguments: logdir: the directory into which to store all the runs' data verbose: if true, print out each run's name as it begins
f7970:m1
def __init__(self, context):
self._multiplexer = context.multiplexer<EOL>self._db_connection_provider = context.db_connection_provider<EOL>
Instantiates ScalarsPlugin via TensorBoard core. Args: context: A base_plugin.TBContext instance.
f7971:c1:m0
def is_active(self):
if self._db_connection_provider:<EOL><INDENT>db = self._db_connection_provider()<EOL>cursor = db.execute(
The scalars plugin is active iff any run has at least one scalar tag.
f7971:c1:m2
def index_impl(self):
if self._db_connection_provider:<EOL><INDENT>db = self._db_connection_provider()<EOL>cursor = db.execute(
Return {runName: {tagName: {displayName: ..., description: ...}}}.
f7971:c1:m3
def scalars_impl(self, tag, run, experiment, output_format):
if self._db_connection_provider:<EOL><INDENT>db = self._db_connection_provider()<EOL>cursor = db.execute(
Result of the form `(body, mime_type)`.
f7971:c1:m4