用法
split(
count=1
)
參數
-
count
要返回的生成器數量。
返回
-
Generator
對象的列表(長度count
)彼此獨立。新生成器具有與舊生成器相同的 RNG 算法。
返回獨立 Generator
對象的列表。
兩個生成器相互獨立,因為它們生成的隨機數流沒有統計上可檢測的相關性。新生成器也獨立於舊生成器。舊生成器的狀態將被更改(與其他隨機數生成方法一樣),因此 split
的兩次調用將返回不同的新生成器。
例如:
gens = get_global_generator().split(count=10)
for gen in gens:
numbers = gen.normal(shape=[2, 3])
# ...
gens2 = get_global_generator().split(count=10)
# gens2 will be different from gens
新生成器將放在當前設備上(可能與舊生成器不同),例如:
with tf.device("/device:CPU:0"):
gen = Generator(seed=1234) # gen is on CPU
with tf.device("/device:GPU:0"):
gens = gen.split(count=10) # gens are on GPU
相關用法
- Python tf.random.Generator.binomial用法及代碼示例
- Python tf.random.Generator.make_seeds用法及代碼示例
- Python tf.random.Generator用法及代碼示例
- Python tf.random.truncated_normal用法及代碼示例
- Python tf.random.stateless_uniform用法及代碼示例
- Python tf.random.shuffle用法及代碼示例
- Python tf.random.stateless_parameterized_truncated_normal用法及代碼示例
- Python tf.random.normal用法及代碼示例
- Python tf.random.experimental.stateless_split用法及代碼示例
- Python tf.random.stateless_poisson用法及代碼示例
- Python tf.random.set_global_generator用法及代碼示例
- Python tf.random.uniform用法及代碼示例
- Python tf.random.categorical用法及代碼示例
- Python tf.random.stateless_binomial用法及代碼示例
- Python tf.random.experimental.stateless_fold_in用法及代碼示例
- Python tf.random.stateless_categorical用法及代碼示例
- Python tf.random.set_seed用法及代碼示例
- Python tf.random.poisson用法及代碼示例
- Python tf.random.gamma用法及代碼示例
- Python tf.random.create_rng_state用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.random.Generator.split。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。