TensorPlay
latest (dev)
Copy
View Markdown

Latest development documentation · Updated 2026-10-15

Generator

class tensorplay.Generator(device='cpu') → Generator

Creates and returns a generator object that manages the state of the algorithm which produces pseudo random numbers. Used as a keyword argument in many in-place random sampling functions.

Parameters:

device (tensorplay.device, optional) – the desired device for the generator.

Returns:

An tensorplay.Generator object.

Return type:

Generator

Example:

>>> g_cpu = tensorplay.Generator()
>>> g_cuda = tensorplay.Generator(device='cuda')
property device

Generator.device -> device

Gets the current device of the generator.

Example:

>>> g_cpu = tensorplay.Generator()
>>> g_cpu.device
device(type='cpu')
get_state(self: tensorplay._C.Generator) → tensorplay::Tensor
initial_seed(self: tensorplay._C.Generator) → int
manual_seed(self: tensorplay._C.Generator, seed: SupportsInt | SupportsIndex) → int
seed(self: tensorplay._C.Generator) → int
set_state(self: tensorplay._C.Generator, new_state: tensorplay::Tensor) → None

On this page

Ask DeepWiki