File tree 2 files changed +27
-10
lines changed 2 files changed +27
-10
lines changed Original file line number Diff line number Diff line change @@ -211,7 +211,8 @@ class DebugNumericSummaryOp : public OpKernel {
211
211
212
212
if (x < min) {
213
213
min = x;
214
- } else if (x > max) {
214
+ }
215
+ if (x > max) {
215
216
max = x;
216
217
}
217
218
Original file line number Diff line number Diff line change @@ -57,17 +57,33 @@ def load_tensor_from_event_file(event_file_path):
57
57
event = event_pb2 .Event ()
58
58
with gfile .Open (event_file_path , "rb" ) as f :
59
59
event .ParseFromString (f .read ())
60
+ return load_tensor_from_event (event )
60
61
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 :
70
83
tensor_value = None
84
+ else :
85
+ # Uninitialized tensor or tensor of unconvertible data type.
86
+ tensor_value = None
71
87
72
88
return tensor_value
73
89
You can’t perform that action at this time.
0 commit comments