How to use the trfl.gen_distribution_ops.project_distribution function in trfl

To help you get started, we’ve selected a few trfl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github deepmind / trfl / trfl / distribution_ops.py View on Github external
Args:
    support: Tensor defining support of a categorical distribution(s). Must be
      of rank 1 or of the same rank as `weights`. The size of the last dimension
      has to match that of `weights`.
    weights: Tensor defining weights on the support points.
    new_support: Tensor holding positions of a new support.
    reverse: Whether to evalute cumulative from the left or right.
  Returns:
    Cumulative distribution on the supplied support.
    The foolowing invariant is maintained across the last dimension:
    result[i] = (sum_j weights[j] for all j where support[j] < new_support[i])
                if reverse == False else
                (sum_j weights[j] for all j where support[j] > new_support[i])
  """
  return gen_distribution_ops.project_distribution(
      support, weights, new_support, 3 if reverse else 2)
github deepmind / trfl / trfl / distribution_ops.py View on Github external
def l2_project(support, weights, new_support):
  """Projects distribution (support, weights) onto new_support.

  Args:
    support: Tensor defining support of a categorical distribution(s). Must be
      of rank 1 or of the same rank as `weights`. The size of the last dimension
      has to match that of `weights`.
    weights: Tensor defining weights on the support points.
    new_support: Tensor holding positions of a new support.
  Returns:
    Projection of (support, weights) onto the new_support.
  """
  return gen_distribution_ops.project_distribution(
      support, weights, new_support, 1)