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

Function _get_diff_for_monotonic_comparison

tensorflow/python/ops/check_ops.py:1856–1869  ·  view source on GitHub ↗

Gets the difference x[1:] - x[:-1].

(x)

Source from the content-addressed store, hash-verified

1854
1855# pylint: disable=line-too-long
1856def _get_diff_for_monotonic_comparison(x):
1857 """Gets the difference x[1:] - x[:-1]."""
1858 x = array_ops.reshape(x, [-1])
1859 if not is_numeric_tensor(x):
1860 raise TypeError('Expected x to be numeric, instead found: %s' % x)
1861
1862 # If x has less than 2 elements, there is nothing to compare. So return [].
1863 is_shorter_than_two = math_ops.less(array_ops.size(x), 2)
1864 short_result = lambda: ops.convert_to_tensor([], dtype=x.dtype)
1865
1866 # With 2 or more elements, return x[1:] - x[:-1]
1867 s_len = array_ops.shape(x) - 1
1868 diff = lambda: array_ops.strided_slice(x, [1], [1] + s_len)- array_ops.strided_slice(x, [0], s_len)
1869 return control_flow_ops.cond(is_shorter_than_two, short_result, diff)
1870
1871
1872@tf_export(

Callers 2

is_non_decreasingFunction · 0.85
is_strictly_increasingFunction · 0.85

Calls 5

is_numeric_tensorFunction · 0.85
reshapeMethod · 0.80
sizeMethod · 0.45
shapeMethod · 0.45
condMethod · 0.45

Tested by

no test coverage detected