本文整理汇总了Python中tensorflow.Event方法的典型用法代码示例。如果您正苦于以下问题:Python tensorflow.Event方法的具体用法?Python tensorflow.Event怎么用?Python tensorflow.Event使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tensorflow
的用法示例。
在下文中一共展示了tensorflow.Event方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _setup_graph
# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import Event [as 别名]
def _setup_graph(self):
# special heuristics for Horovod
from ..train import HorovodTrainer
if isinstance(self.trainer, HorovodTrainer):
if self.trainer.mpi_enabled():
logger.warn("GPUUtilizationTracker is disabled under MPI.")
self._enabled = False
return
else:
self._devices = [self.trainer.hvd.local_rank()]
if self._devices is None:
self._devices = self._guess_devices()
assert len(self._devices), "[GPUUtilizationTracker] No GPU device given!"
self._evt = mp.Event()
self._stop_evt = mp.Event()
self._queue = mp.Queue()
self._proc = mp.Process(target=self.worker, args=(
self._evt, self._queue, self._stop_evt, self._devices))
ensure_proc_terminate(self._proc)
start_proc_mask_signal(self._proc)
示例2: on_graph_def
# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import Event [as 别名]
def on_graph_def(self, graph_def, device_name, wall_time):
"""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 TensorBoard. For example, the GraphDef in general
TensorBoard may get partitioned for multiple devices (CPUs and GPUs),
each of which will generate a GraphDef event proto sent to this
method.
device_name: Name of the device on which the graph was created.
wall_time: An epoch timestamp (in microseconds) for the graph.
"""
# For now, we do nothing with the graph def. However, we must define this
# method to satisfy the handler's interface. Furthermore, we may use the
# graph in the future (for instance to provide a graph if there is no graph
# provided otherwise).
del wall_time
self._graph_defs[device_name] = graph_def
if not self._graph_defs_arrive_first:
self._add_graph_def(device_name, graph_def)
self._incoming_channel.get()
示例3: tb_add_histogram
# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import Event [as 别名]
def tb_add_histogram(experiment, name, wall_time, step, histo):
# Tensorflow does not support key being unicode
histo_string = {}
for k,v in histo.items():
histo_string[str(k)] = v
histo = histo_string
writer = tb_get_xp_writer(experiment)
summary = tf.Summary(value=[
tf.Summary.Value(tag=name, histo=histo),
])
event = tf.Event(wall_time=wall_time, step=step, summary=summary)
writer.add_event(event)
writer.flush()
tb_modified_xp(experiment, modified_type="histograms", wall_time=wall_time)
# Perform requests to tensorboard http api
示例4: Load
# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import Event [as 别名]
def Load(self):
"""Loads all new values from disk.
Calling Load multiple times in a row will not 'drop' events as long as the
return value is not iterated over.
Yields:
All values that were written to disk that have not been yielded yet.
"""
tf.logging.debug('Loading events from %s', self._file_path)
while True:
try:
with tf.errors.raise_exception_on_not_ok_status() as status:
self._reader.GetNext(status)
except (tf.errors.DataLossError, tf.errors.OutOfRangeError):
# We ignore partial read exceptions, because a record may be truncated.
# PyRecordReader holds the offset prior to the failed read, so retrying
# will succeed.
break
event = tf.Event()
event.ParseFromString(self._reader.record())
yield event
tf.logging.debug('No more events in %s', self._file_path)
开发者ID:PacktPublishing,项目名称:Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda,代码行数:25,代码来源:event_file_loader.py
示例5: on_graph_def
# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import Event [as 别名]
def on_graph_def(self, graph_def, device_name, wall_time):
"""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 TensorBoard. For example, the GraphDef in general
TensorBoard may get partitioned for multiple devices (CPUs and GPUs),
each of which will generate a GraphDef event proto sent to this
method.
device_name: Name of the device on which the graph was created.
wall_time: An epoch timestamp (in microseconds) for the graph.
"""
# For now, we do nothing with the graph def. However, we must define this
# method to satisfy the handler's interface. Furthermore, we may use the
# graph in the future (for instance to provide a graph if there is no graph
# provided otherwise).
del device_name
del wall_time
del graph_def
开发者ID:PacktPublishing,项目名称:Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda,代码行数:23,代码来源:debugger_server_lib.py
示例6: WriteScalarSeries
# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import Event [as 别名]
def WriteScalarSeries(writer, tag, f, n=5):
"""Write a series of scalar events to writer, using f to create values."""
step = 0
wall_time = _start_time
for i in xrange(n):
v = f(i)
value = tf.Summary.Value(tag=tag, simple_value=v)
summary = tf.Summary(value=[value])
event = tf.Event(wall_time=wall_time, step=step, summary=summary)
writer.add_event(event)
step += 1
wall_time += 10
示例7: WriteHistogramSeries
# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import Event [as 别名]
def WriteHistogramSeries(writer, tag, mu_sigma_tuples, n=20):
"""Write a sequence of normally distributed histograms to writer."""
step = 0
wall_time = _start_time
for [mean, stddev] in mu_sigma_tuples:
data = [random.normalvariate(mean, stddev) for _ in xrange(n)]
histo = _MakeHistogram(data)
summary = tf.Summary(value=[tf.Summary.Value(tag=tag, histo=histo)])
event = tf.Event(wall_time=wall_time, step=step, summary=summary)
writer.add_event(event)
step += 10
wall_time += 100
示例8: _before_train
# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import Event [as 别名]
def _before_train(self):
assert gpu_available_in_session(), "[GPUUtilizationTracker] needs GPU!"
self._evt = mp.Event()
self._stop_evt = mp.Event()
self._queue = mp.Queue()
self._proc = mp.Process(target=self.worker, args=(
self._evt, self._queue, self._stop_evt))
ensure_proc_terminate(self._proc)
start_proc_mask_signal(self._proc)
示例9: _write_event
# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import Event [as 别名]
def _write_event(self, metadata):
evt = tf.Event()
evt.tagged_run_metadata.tag = 'trace-{}'.format(self.global_step)
evt.tagged_run_metadata.run_metadata = metadata.SerializeToString()
self.trainer.monitors.put_event(evt)
示例10: WriteScalarSeries
# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import Event [as 别名]
def WriteScalarSeries(writer, tag, f, n=5):
"""Write a series of scalar events to writer, using f to create values."""
step = 0
wall_time = _start_time
for i in xrange(n):
v = f(i)
value = tf.Summary.Value(tag=tag, simple_value=v)
summary = tf.Summary(value=[value])
event = tf.Event(wall_time=wall_time, step=step, summary=summary)
writer.add_event(event)
step += 1
wall_time += 10
示例11: WriteHistogramSeries
# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import Event [as 别名]
def WriteHistogramSeries(writer, tag, mu_sigma_tuples, n=20):
"""Write a sequence of normally distributed histograms to writer."""
step = 0
wall_time = _start_time
for [mean, stddev] in mu_sigma_tuples:
data = [random.normalvariate(mean, stddev) for _ in xrange(n)]
histo = _MakeHistogram(data)
summary = tf.Summary(value=[tf.Summary.Value(tag=tag, histo=histo)])
event = tf.Event(wall_time=wall_time, step=step, summary=summary)
writer.add_event(event)
step += 10
wall_time += 100
示例12: _extract_device_name_from_event
# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import Event [as 别名]
def _extract_device_name_from_event(event):
"""Extract device name from a tf.Event proto carrying tensor value."""
plugin_data_content = json.loads(
tf.compat.as_str(event.summary.value[0].metadata.plugin_data.content)
)
return plugin_data_content["device"]
示例13: on_core_metadata_event
# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import Event [as 别名]
def on_core_metadata_event(self, event):
"""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 details.
"""
core_metadata = json.loads(event.log_message.message)
input_names = ",".join(core_metadata["input_names"])
output_names = ",".join(core_metadata["output_names"])
target_nodes = ",".join(core_metadata["target_nodes"])
self._run_key = RunKey(input_names, output_names, target_nodes)
if not self._graph_defs:
self._graph_defs_arrive_first = False
else:
for device_name in self._graph_defs:
self._add_graph_def(device_name, self._graph_defs[device_name])
self._outgoing_channel.put(
_comm_metadata(self._run_key, event.wall_time)
)
# Wait for acknowledgement from client. Blocks until an item is got.
logger.info("on_core_metadata_event() waiting for client ack (meta)...")
self._incoming_channel.get()
logger.info("on_core_metadata_event() client ack received (meta).")
# TODO(cais): If eager mode, this should return something to yield.
示例14: _CreateEventWithDebugNumericSummary
# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import Event [as 别名]
def _CreateEventWithDebugNumericSummary(
self, device_name, op_name, output_slot, wall_time, step, list_of_values
):
"""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.
output_slot: The numeric output slot for the tensor.
wall_time: The numeric wall time of the event.
step: The step of the event.
list_of_values: A python list of values within the tensor.
Returns:
A `tf.Event` with a health pill summary.
"""
event = tf.compat.v1.Event(step=step, wall_time=wall_time)
tensor = tf.compat.v1.make_tensor_proto(
list_of_values, dtype=tf.float64, shape=[len(list_of_values)]
)
value = event.summary.value.add(
tag=op_name,
node_name="%s:%d:DebugNumericSummary" % (op_name, output_slot),
tensor=tensor,
)
content_proto = debugger_event_metadata_pb2.DebuggerEventMetadata(
device=device_name, output_slot=output_slot
)
value.metadata.plugin_data.plugin_name = constants.DEBUGGER_PLUGIN_NAME
value.metadata.plugin_data.content = tf.compat.as_bytes(
json_format.MessageToJson(
content_proto, including_default_value_fields=True
)
)
return event
示例15: tb_add_scalar
# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import Event [as 别名]
def tb_add_scalar(experiment, name, wall_time, step, value):
writer = tb_get_xp_writer(experiment)
summary = tf.Summary(value=[
tf.Summary.Value(tag=name, simple_value=value),
])
event = tf.Event(wall_time=wall_time, step=step, summary=summary)
writer.add_event(event)
writer.flush()
tb_modified_xp(experiment, modified_type="scalars", wall_time=wall_time)