LostTech.TensorFlow : API Documentation

Type tf.random.experimental

Namespace tensorflow

Public static methods

object create_rng_state(Nullable<int> seed, Nullable<int> algorithm)

Creates a RNG state.
Parameters
Nullable<int> seed
an integer or 1-D tensor.
Nullable<int> algorithm
an integer representing the RNG algorithm.
Returns
object
a 1-D tensor whose size depends on the algorithm.

object create_rng_state_dyn(object seed, object algorithm)

Creates a RNG state.
Parameters
object seed
an integer or 1-D tensor.
object algorithm
an integer representing the RNG algorithm.
Returns
object
a 1-D tensor whose size depends on the algorithm.

Generator get_global_generator()

object get_global_generator_dyn()

void set_global_generator(Generator generator)

Replaces the global generator with another `Generator` object.

This function creates a new Generator object (and the Variable object within), which does not work well with tf.function because (1) tf.function puts restrictions on Variable creation thus reset_global_generator can't be freely used inside tf.function; (2) redirecting a global variable to a new object is problematic with tf.function because the old object may be captured by a 'tf.function'ed function and still be used by it. A 'tf.function'ed function only keeps weak references to variables, so deleting a variable and then calling that function again may raise an error, as demonstrated by random_test.py/RandomTest.testResetGlobalGeneratorBadWithDefun.
Parameters
Generator generator
the new `Generator` object.

object set_global_generator_dyn(object generator)

Replaces the global generator with another `Generator` object.

This function creates a new Generator object (and the Variable object within), which does not work well with tf.function because (1) tf.function puts restrictions on Variable creation thus reset_global_generator can't be freely used inside tf.function; (2) redirecting a global variable to a new object is problematic with tf.function because the old object may be captured by a 'tf.function'ed function and still be used by it. A 'tf.function'ed function only keeps weak references to variables, so deleting a variable and then calling that function again may raise an error, as demonstrated by random_test.py/RandomTest.testResetGlobalGeneratorBadWithDefun.
Parameters
object generator
the new `Generator` object.

Public properties

PythonFunctionContainer create_rng_state_fn get;

PythonFunctionContainer get_global_generator_fn get;

PythonFunctionContainer set_global_generator_fn get;