torch.func._random.normal#
- torch.func._random.normal(key, *shape, mean=0.0, std=1.0, dtype=None)[source]#
Generate normally distributed random values from a PRNG key.
Produces a tensor of the given shape filled with values drawn from a normal distribution with the specified
meanandstd. The output is fully determined by the key, so calling with the same key always returns the same result. The output is placed on the same device askey.Supports batched keys: if
keyhas shape(*batch, K), the leading dimensions ofshapemust be broadcastable with*batchand each key independently generates its slice of the output.- Parameters:
key (Tensor) – A PRNG key returned by
key(),split(), orfold_in().*shape (int) – The desired output shape.
mean (float) – Mean of the normal distribution. Default:
0.0.std (float) – Standard deviation of the normal distribution. Default:
1.0.dtype (
torch.dtype, optional) – The desired dtype. Default:torch.float32.
- Returns:
A tensor of the given shape filled with normal random values.
- Return type:
Example:
>>> key = torch.func._random.key(42, device="cuda") >>> torch.func._random.normal(key, (1000,))