Skip to content

check_random_state_torch

check_random_state_torch(random_state, device='cpu')

Return a seeded torch.Generator from an int or None.

Parameters:

  • random_state (int or None) –

    Seed value. If None, a random seed is drawn from the default global generator.

  • device (str or device, default: "cpu" ) –

    Device on which the generator will live.

Returns:

  • Generator –

    A generator seeded deterministically when random_state is an int, or seeded randomly when it is None.