從泊鬆分布輸出確定性偽隨機值。
用法
tf.random.stateless_poisson(
shape, seed, lam, dtype=tf.dtypes.int32, name=None
)參數
-
shape一維整數張量或 Python 數組。輸出張量的形狀。 -
seed形狀 [2] 張量,隨機數生成器的種子。必須具有數據類型int32或int64。 (使用 XLA 時,僅允許使用int32。) -
lam張量。泊鬆分布的速率參數"lambda"。形狀必須與shape的最右側尺寸相匹配。 -
dtype樣本的 Dtype(允許使用 int 或 float dtype,因為樣本是離散的)。默認值:int32。 -
name操作的名稱(可選)。
返回
-
samples用隨機泊鬆值填充的指定形狀的張量。對於每個 i,每個samples[..., i]都是來自 Poisson 分布的獨立抽取,速率為lam[i]。
生成的值遵循具有指定速率參數的泊鬆分布。
這是tf.random.poisson 的無狀態版本:如果使用相同的種子和形狀運行兩次,它將產生相同的偽隨機數。在同一硬件上多次運行的輸出是一致的,但可能會在 TensorFlow 版本之間或在非 CPU/GPU 硬件上發生變化。
stateless_poisson 和 poisson 之間的 shape 參數的解釋存在細微差別:在 poisson 中,shape 始終位於 lam 的形狀之前;而在 stateless_poisson 中, lam 的形狀必須與 shape 的尾隨尺寸匹配。
例子:
samples = tf.random.stateless_poisson([10, 2], seed=[12, 34], lam=[5, 15])
# samples has shape [10, 2], where each slice [:, 0] and [:, 1] represents
# the samples drawn from each distribution
samples = tf.random.stateless_poisson([7, 5, 2], seed=[12, 34], lam=[5, 15])
# samples has shape [7, 5, 2], where each slice [:,:, 0] and [:,:, 1]
# represents the 7x5 samples drawn from each of the two distributions
rate = tf.constant([[1.], [3.], [5.]])
samples = tf.random.stateless_poisson([30, 3, 1], seed=[12, 34], lam=rate)
# samples has shape [30, 3, 1], with 30 samples each of 3x1 distributions.
相關用法
- Python tf.random.stateless_parameterized_truncated_normal用法及代碼示例
- Python tf.random.stateless_uniform用法及代碼示例
- Python tf.random.stateless_binomial用法及代碼示例
- Python tf.random.stateless_categorical用法及代碼示例
- Python tf.random.stateless_gamma用法及代碼示例
- Python tf.random.shuffle用法及代碼示例
- Python tf.random.set_global_generator用法及代碼示例
- Python tf.random.set_seed用法及代碼示例
- Python tf.random.truncated_normal用法及代碼示例
- Python tf.random.Generator用法及代碼示例
- Python tf.random.Generator.binomial用法及代碼示例
- Python tf.random.normal用法及代碼示例
- Python tf.random.experimental.stateless_split用法及代碼示例
- Python tf.random.uniform用法及代碼示例
- Python tf.random.categorical用法及代碼示例
- Python tf.random.experimental.stateless_fold_in用法及代碼示例
- Python tf.random.Generator.make_seeds用法及代碼示例
- Python tf.random.poisson用法及代碼示例
- Python tf.random.gamma用法及代碼示例
- Python tf.random.create_rng_state用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.random.stateless_poisson。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
