Этот файл создано:
Код: Выделить всё
tensorboard_callback = tf.keras.callbacks.TensorBoard(log_dir=logdir, profile_batch=(1,20))
# Train the model with profiling enabled
history = model.fit(train_dataset, validation_data=validation_dataset, epochs=epochs, callbacks=[tensorboard_callback])
Код: Выделить всё
import tensorflow as tf
def extract_event_data(event_file):
# Load the event file using EventFileLoader
event_file_loader = tf.compat.v1.train.summary_iterator(event_file)
for event in event_file_loader:
# Extract tagged_run_metadata if it exists
if event.tagged_run_metadata:
print(f'Event Tagged Metadata: {event.tagged_run_metadata}')
tag = event.tagged_run_metadata.tag
run_metadata = event.tagged_run_metadata.run_metadata
print(f"Tag: {tag}")
print("Run Metadata (Serialized):", run_metadata)
# Iterate over each value in the summary for metrics or tensor data
for value in event.summary.value:
# Print the tag and plugin name if available
print(f'{value.tag} - {value.metadata.plugin_data.plugin_name}')
# Check and print simple scalar values (e.g., loss, accuracy)
if value.HasField("simple_value"):
print(f"Step: {event.step}, Tag: {value.tag}, Value: {value.simple_value}")
# Check and print tensor data, such as histograms or other structured data
elif value.HasField("tensor"):
tensor_data = tf.make_ndarray(value.tensor)
print(f"Step: {event.step}, Tag: {value.tag}, Tensor Shape: {tensor_data.shape}")
# Optionally, you can print the tensor's content if it's small
if tensor_data.size < 100: # Display only small tensors to avoid excessive output
print(f"Tensor Data:\n{tensor_data}")
extract_event_data(event_file_path)
На самом деле я ищу граф вычислений (с операционными узлами и их входные данные) и информацию трассировки событий после профилирования.
Любые ответы приветствуются.
Подробнее здесь: https://stackoverflow.com/questions/791 ... n-215490-0