Skip to content

Commit fa19f2f

Browse files
caisqtensorflower-gardener
authored andcommitted
tfdbg: Fix a bug in DebugNumericSummaryOp's min / max calculation algorithm
Change: 148178117
1 parent 542c3cb commit fa19f2f

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

tensorflow/core/kernels/debug_ops.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ class DebugNumericSummaryOp : public OpKernel {
211211

212212
if (x < min) {
213213
min = x;
214-
} else if (x > max) {
214+
}
215+
if (x > max) {
215216
max = x;
216217
}
217218

tensorflow/python/debug/lib/debug_data.py

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,33 @@ def load_tensor_from_event_file(event_file_path):
5757
event = event_pb2.Event()
5858
with gfile.Open(event_file_path, "rb") as f:
5959
event.ParseFromString(f.read())
60+
return load_tensor_from_event(event)
6061

61-
if (event.summary.value[0].tensor.tensor_content or
62-
event.summary.value[0].tensor.string_val):
63-
# Initialized tensor.
64-
try:
65-
tensor_value = tensor_util.MakeNdarray(event.summary.value[0].tensor)
66-
except KeyError:
67-
tensor_value = None
68-
else:
69-
# Uninitialized tensor or tensor of unconvertible data type.
62+
63+
def load_tensor_from_event(event):
64+
"""Load a tensor from an Event proto.
65+
66+
Args:
67+
event: The Event proto, assumed to hold a tensor value in its
68+
summary.value[0] field.
69+
70+
Returns:
71+
The tensor value loaded from the event file, as a `numpy.ndarray`. For
72+
uninitialized Tensors, returns `None`. For Tensors of data types that
73+
cannot be converted to `numpy.ndarray` (e.g., `tf.resource`), return
74+
`None`.
75+
"""
76+
77+
if (event.summary.value[0].tensor.tensor_content or
78+
event.summary.value[0].tensor.string_val):
79+
# Initialized tensor.
80+
try:
81+
tensor_value = tensor_util.MakeNdarray(event.summary.value[0].tensor)
82+
except KeyError:
7083
tensor_value = None
84+
else:
85+
# Uninitialized tensor or tensor of unconvertible data type.
86+
tensor_value = None
7187

7288
return tensor_value
7389

0 commit comments

Comments
 (0)