tensorflow / tensorflow/models
View or dump full tensor values from the Graph Execution of a DetectionModel?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.7k
- Forks
- 44.8k
- PR merge metrics
- No merged PRs in 30d
Description
Prerequisites
1. The entire URL of the file you are using
2. Describe the feature you request
I am trying to dump/view intermediate tensor values in a model created using the TF2 ObjectDetector API. Specifically the 'ssd_mobilenet_v2_320x320_coco17_tpu-8' model.
I am trying to use the tf.debugging.experimental.enable_dump_debug_info for this using TensorBoard with Debugger V2 (https://www.tensorflow.org/tensorboard/debugger_v2) as follows:
import argparse
import sys
import os
import pathlib
import absl
import tensorflow as tf
import numpy as np
from object_detection.builders import model_builder
from object_detection.utils import config_util
tf.debugging.experimental.enable_dump_debug_info(
'./dumpdir',
tensor_debug_mode='SHAPE',
circular_buffer_size=-1)
model_name = 'ssd_mobilenet_v2_320x320_coco17_tpu-8'
pipeline_config = os.path.join('./models/research/object_detection/configs/tf2/',
model_name + '.config')
model_dir = './models/research/object_detection/test_data/checkpoint/'
configs = config_util.get_configs_from_pipeline_file(pipeline_config)
model_config = configs['model']
detection_model = model_builder.build(model_config=model_config, is_training=False)
@tf.function
def detect_fn(model, image):
"""Detect objects in image."""
image, shapes = model.preprocess(image)
prediction_dict = model.predict(image, shapes)
detections = model.postprocess(prediction_dict, shapes)
return detections, prediction_dict, tf.reshape(shapes, [-1])
# Evaluation Step
X = np.ones([1, 320, 320, 3])
image = tf.convert_to_tensor(X, dtype=tf.float32)
detections, predictions_dict, shapes = detect_fn(detection_model, image)
print("Model finished executing")
I understand that none of the 5 tensor_debug_mode options for tf.debugging.experimental.enable_dump_debug_info allow for displaying or dumping tensors produced during the Graph execution. At most we can see the datatype, dimesions, shape and size of these tensors. For example, in the image below, we can see these 4 attributes of the tensor Postprocessor/Decode/get_center_coordinates_and_sizes/sub_1:0, (which are: float32 1D shape:[1917] size:1917) :

I am wondering if it is possible to somehow view or dump the actual value of these tensors, i.e.:
- Is there a way to view or dump the numeric values present in the tensors, for example the 1917 values in
Postprocessor/Decode/get_center_coordinates_and_sizes/sub_1:0? - Is it possible to do this using the Debugger V2 and TensorBoard?
- Is it possible to do this in some other way, without modifying the
object_detectionAPI code?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.