Tensor.random¶
Create a tensor with all admissible blocks filled with random values.
random
classmethod
¶
random(
indices: Sequence[Index],
dtype: dtype = torch.float64,
seed: Optional[int] = None,
itags: Optional[Sequence[str]] = None,
device: Optional[Union[str, device]] = None,
requires_grad: bool = False,
) -> Tensor
Create a tensor filled with random values for each admissible block.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indices
|
Sequence[Index]
|
Sequence of Index objects defining the tensor structure |
required |
dtype
|
dtype
|
Data type for the tensor blocks (default: torch.float64) |
float64
|
seed
|
int
|
Random seed for reproducibility |
None
|
itags
|
Sequence[str]
|
Tags for each index (default: "init" for all) |
None
|
device
|
str or device
|
Device to place tensors on (default: current default device) |
None
|
requires_grad
|
bool
|
If True, enables gradient tracking for this tensor (default: False) |
False
|
Notes
Gradient tracking follows PyTorch's default behavior. Set requires_grad=True to enable autograd for this tensor. Use torch.no_grad() context to temporarily disable gradient computation during operations.
MPS (Apple Silicon) doesn't support float64/complex128. If creating on MPS with these dtypes, they will be automatically downgraded to float32/complex64.
For generic symmetry groups (e.g., SU2), intertwiners (intw) are automatically populated with Bridge objects containing default Clebsch-Gordan specifications.
Description¶
Creates a new tensor with random values in all charge-conserving blocks. Random values are drawn from a standard normal distribution. Use the seed parameter for reproducibility.
See Also¶
- zeros: Create zero tensor
- Tensor: Main tensor class
- Examples: First Tensor
Notes¶
- Random values from standard normal: mean=0, std=1
- Use
seedparameter for reproducible results - Only admissible blocks are created and filled