(x, axis=-1)
return d
Take the finite difference of a tensor along an axis.

  Args:
    x: Input tensor of any dimension.
    axis: Axis on which to take the finite difference.

  Returns:
    d: Tensor with size less than x by 1 along the difference dimension.

  Raises:
    ValueError: Axis out of range for tensor.
Take the finite difference of a tensor along an axis.
Take the finite difference of a tensor along an axis .
def diff(x, axis=-1):
  """Take the finite difference of a tensor along an axis.

  Args:
    x: Input tensor of any dimension.
    axis: Axis on which to take the finite difference.

  Returns:
    d: Tensor with size less than x by 1 along the difference dimension.

  Raises:
    ValueError: Axis out of range for tensor.
  """
  shape = x.get_shape()
  if axis >= len(shape):
    raise ValueError('Invalid axis index: %d for tensor with only %d axes.' %
                     (axis, len(shape)))

  begin_back = [0 for unused_s in range(len(shape))]
  begin_front = [0 for unused_s in range(len(shape))]
  begin_front[axis] = 1

  size = shape.as_list()
  size[axis] -= 1
  slice_front = tf.slice(x, begin_front, size)
  slice_back = tf.slice(x, begin_back, size)
  d = slice_front - slice_back
  return d
def diff ( x , axis = - 1 ) : shape = x . get_shape ( ) if axis >= len ( shape ) : raise ValueError ( 'Invalid axis index: %d for tensor with only %d axes.' % ( axis , len ( shape ) ) ) begin_back = [ 0 for unused_s in range ( len ( shape ) ) ] begin_front = [ 0 for unused_s in range ( len ( shape ) ) ] begin_front [ axis ] = 1 size = shape . as_list ( ) size [ axis ] -= 1 slice_front = tf . slice ( x , begin_front , size ) slice_back = tf . slice ( x , begin_back , size ) d = slice_front - slice_back return d