tensorflow_probability/python/bijectors/categorical_to_discrete.py
def _maybe_check_valid_map_values(map_values, validate_args):
  """Validate `map_values` if `validate_args`==True."""
  assertions = []

  message = 'Rank of map_values must be 1.'
  if tensorshape_util.rank(map_values.shape) is not None:
    if tensorshape_util.rank(map_values.shape) != 1:
      raise ValueError(message)
  elif validate_args:
    assertions.append(assert_util.assert_rank(map_values, 1, message=message))

  message = 'Size of map_values must be greater than 0.'
  if tensorshape_util.num_elements(map_values.shape) is not None:
    if tensorshape_util.num_elements(map_values.shape) == 0:
      raise ValueError(message)
  elif validate_args:
    assertions.append(
        assert_util.assert_greater(
            tf.size(input=map_values), 0, message=message))

  if validate_args:
    assertions.append(
        assert_util.assert_equal(
            tf.math.is_strictly_increasing(map_values),
            True,
            message='map_values is not strictly increasing.'))

  return assertions
def _maybe_check_valid_map_values(map_values, validate_args):
  assertions = []

  message = 'Rank of map_values must be 1.'
  if tensorshape_util.rank(map_values.shape) is not None:
    if tensorshape_util.rank(map_values.shape) != 1:
      raise ValueError(message)
  elif validate_args:
    assertions.append(assert_util.assert_rank(map_values, 1, message=message))

  message = 'Size of map_values must be greater than 0.'
  if tensorshape_util.num_elements(map_values.shape) is not None:
    if tensorshape_util.num_elements(map_values.shape) == 0:
      raise ValueError(message)
  elif validate_args:
    assertions.append(
        assert_util.assert_greater(
            tf.size(input=map_values), 0, message=message))

  if validate_args:
    assertions.append(
        assert_util.assert_equal(
            tf.math.is_strictly_increasing(map_values),
            True,
            message='map_values is not strictly increasing.'))

  return assertions
def _maybe_check_valid_map_values ( map_values , validate_args ) : assertions = [ ] message = 'Rank of map_values must be 1.' if tensorshape_util . rank ( map_values . shape ) is not None : if tensorshape_util . rank ( map_values . shape ) != 1 : raise ValueError ( message ) elif validate_args : assertions . append ( assert_util . assert_rank ( map_values , 1 , message = message ) ) message = 'Size of map_values must be greater than 0.' if tensorshape_util . num_elements ( map_values . shape ) is not None : if tensorshape_util . num_elements ( map_values . shape ) == 0 : raise ValueError ( message ) elif validate_args : assertions . append ( assert_util . assert_greater ( tf . size ( input = map_values ) , 0 , message = message ) ) if validate_args : assertions . append ( assert_util . assert_equal ( tf . math . is_strictly_increasing ( map_values ) , True , message = 'map_values is not strictly increasing.' ) ) return assertions
Validate `map_values` if `validate_args`==True.
Validate map_values if validate_args == True .