(tensor, scalar)
return tf.concat(
      [tensor,
       tf.ones([shape[i] for i in range(ndims - 1)] + [1]) * scalar],
      axis=ndims - 1)
Concatenates a scalar to the last dimension of a tensor.

  Args:
    tensor: A `Tensor`.
    scalar: a scalar `Tensor` to concatenate to tensor `tensor`.

  Returns:
    A `Tensor`. If `tensor` has shape [...,N], the result R has shape
    [...,N+1] and R[...,N] = scalar.

  Raises:
    ValueError: If `tensor` is a scalar `Tensor`.
Concatenates a scalar to the last dimension of a tensor.
Concatenates a scalar to the last dimension of a tensor .
def scalar_concat(tensor, scalar):
  """Concatenates a scalar to the last dimension of a tensor.

  Args:
    tensor: A `Tensor`.
    scalar: a scalar `Tensor` to concatenate to tensor `tensor`.

  Returns:
    A `Tensor`. If `tensor` has shape [...,N], the result R has shape
    [...,N+1] and R[...,N] = scalar.

  Raises:
    ValueError: If `tensor` is a scalar `Tensor`.
  """
  ndims = tensor.shape.ndims
  if ndims < 1:
    raise ValueError('`tensor` must have number of dimensions >= 1.')
  shape = tf.shape(tensor)
  return tf.concat(
      [tensor,
       tf.ones([shape[i] for i in range(ndims - 1)] + [1]) * scalar],
      axis=ndims - 1)
def scalar_concat ( tensor , scalar ) : ndims = tensor . shape . ndims if ndims < 1 : raise ValueError ( '`tensor` must have number of dimensions >= 1.' ) shape = tf . shape ( tensor ) return tf . concat ( [ tensor , tf . ones ( [ shape [ i ] for i in range ( ndims - 1 ) ] + [ 1 ] ) * scalar ] , axis = ndims - 1 )