histogramdd

class deepinv.physics.functional.histogramdd(x: Tensor, bins: int | Sequence[int] = 10, low: float | Sequence[float] | None = None, upp: float | Sequence[float] | None = None, bounded: bool = False, weights: Tensor | None = None, sparse: bool = False, edges: Tensor | Sequence[Tensor] | None = None)[source]

Bases:

Computes the multidimensional histogram of a tensor.

This is a torch implementation of numpy.histogramdd. This function is borrowed from torchist.

Note

Similar to numpy.histogram, all bins are half-open except the last bin which also includes the upper bound.

Parameters:
  • x (torch.Tensor) – A tensor, (*, D).

  • bins (int, sequence[int]) – The number of bins in each dimension, scalar or (D,).

  • low (float, sequence[float]) – The lower bound in each dimension, scalar or (D,). If low is None, the min of x is used instead.

  • upp (float, sequence[float]) – The upper bound in each dimension, scalar or (D,). If upp is None, the max of x is used instead.

  • bounded (bool) – Whether x is bounded by low and upp, included. If False, out-of-bounds values are filtered out.

  • weights (torch.Tensor) – A tensor of weights, (*,). Each sample of x contributes its associated weight towards the bin count (instead of 1).

  • sparse (bool) – Whether the histogram is returned as a sparse tensor or not.

  • edges (torch.Tensor, sequence[torch.Tensor]) – The edges of the histogram. Either a vector or a list of vectors. If provided, bins, low and upp are inferred from edges.

Returns:

(torch.Tensor) : the histogram