kaira.data.create_binary_tensor

kaira.data.create_binary_tensor(size: List[int] | Size | int, prob: float = 0.5, device: device | None = None, dtype: dtype | None = None) Tensor[source]

Create a random binary tensor with specified probability of 1s.

Parameters:
  • size – Shape of the tensor to generate

  • prob – Probability of generating 1s (default: 0.5 for uniform distribution)

  • device – Device to create the tensor on (default: None, uses default device)

  • dtype – Data type of the tensor (default: None, uses default dtype)

Returns:

A binary tensor with random 0s and 1s according to the specified probability