A Philox-4×32 random stream of its own.
Pass one as generator= to a random op to draw from it instead of the
default stream that lucid.manual_seed controls; draws through it
leave the default stream where it was.
Parameters
seedint= 00.Raises
TypeErrorseed is not an integer.ValueErrorseed is out of the 64-bit range.Notes
The reference's constructor takes a device; a Lucid stream is
device-independent, so there is none. seed reseeds from
entropy, as the reference's does; initial_seed reads the key.
Examples
>>> import lucid
>>> g = lucid.Generator().manual_seed(7)
>>> g.initial_seed()
7
>>> a = lucid.rand(3, generator=g)
>>> state = g.get_state()
>>> b = lucid.rand(3, generator=g)
>>> c = lucid.rand(3, generator=g.set_state(state))
>>> bool((b == c).all())
TrueConstructors
1Instance methods
5The stream's position, [key, counter], as an int64 tensor.
Returns
TensorShape (2,); set_state returns the stream to it.
The key this stream was last seeded with.
Returns
intThe key, in .
Set the key to seed and rewind the stream to its start.
Parameters
seedintReturns
GeneratorThis generator, so a call can be chained.
Reseed the stream from the OS entropy source and return the new key.
Returns
intThe key, in ; manual_seed with it
replays the stream from here.