MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / compare

Method compare

tensorflow/contrib/learn/python/learn/monitors.py:915–954  ·  view source on GitHub ↗

Compares two `GraphDump` monitors and returns differences. Args: other_dump: Another `GraphDump` monitor. step: `int`, step to compare on. atol: `float`, absolute tolerance in comparison of floating arrays. Returns: Returns tuple: matched: `list` of keys tha

(self, other_dump, step, atol=1e-06)

Source from the content-addressed store, hash-verified

913
914 # TODO(ptucker): Handle keys that are in one but not the other.
915 def compare(self, other_dump, step, atol=1e-06):
916 """Compares two `GraphDump` monitors and returns differences.
917
918 Args:
919 other_dump: Another `GraphDump` monitor.
920 step: `int`, step to compare on.
921 atol: `float`, absolute tolerance in comparison of floating arrays.
922
923 Returns:
924 Returns tuple:
925 matched: `list` of keys that matched.
926 non_matched: `dict` of keys to tuple of 2 mismatched values.
927
928 Raises:
929 ValueError: if a key in `data` is missing from `other_dump` at `step`.
930 """
931 non_matched = {}
932 matched = []
933 this_output = self.data[step] if step in self.data else {}
934 other_output = other_dump.data[step] if step in other_dump.data else {}
935 for key in this_output:
936 if not isinstance(key, six.string_types):
937 continue
938 if key not in other_output:
939 raise ValueError("%s missing at step %s.", (key, step))
940 value1 = _extract_output(this_output, key)
941 value2 = _extract_output(other_output, key)
942 if isinstance(value1, str):
943 continue
944 if isinstance(value1, np.ndarray):
945 if not np.allclose(value1, value2, atol=atol):
946 non_matched[key] = value1 - value2
947 else:
948 matched.append(key)
949 else:
950 if value1 != value2:
951 non_matched[key] = (value1, value2)
952 else:
953 matched.append(key)
954 return matched, non_matched
955
956
957class ExportMonitor(EveryN):

Callers 15

test_graph_dumpMethod · 0.95
set_deviceFunction · 0.45
RecvFromRemoteAsyncMethod · 0.45
RdmaMgrMethod · 0.45
SetupChannelsMethod · 0.45
SafeDebugPathFunction · 0.45
IsLegacyCallInstructionFunction · 0.45
ClampMethod · 0.45
FindEntryMethod · 0.45
IsNHWCMethod · 0.45
UpdateAttrDataFormatMethod · 0.45
CollapseMethod · 0.45

Calls 2

_extract_outputFunction · 0.85
appendMethod · 0.45

Tested by 4

test_graph_dumpMethod · 0.76
operator()Method · 0.36
TestMultipleWritesFunction · 0.36
SetUpMethod · 0.36