tf.random.stateless_binomial
Stay organized with collections
Save and categorize content based on your preferences.
Outputs deterministic pseudorandom values from a binomial distribution.
tf.random.stateless_binomial(
shape, seed, counts, probs, output_dtype=tf.dtypes.int32, name=None
)
The generated values follow a binomial distribution with specified count and
probability of success parameters.
This is a stateless version of tf.random.Generator.binomial
: if run twice
with the same seeds, it will produce the same pseudorandom numbers. The
output is consistent across multiple runs on the same hardware (and between
CPU and GPU), but may change between versions of TensorFlow or on non-CPU/GPU
hardware.
Example:
counts = [10., 20.]
# Probability of success.
probs = [0.8]
binomial_samples = tf.random.stateless_binomial(
shape=[2], seed=[123, 456], counts=counts, probs=probs)
counts = ... # Shape [3, 1, 2]
probs = ... # Shape [1, 4, 2]
shape = [3, 4, 3, 4, 2]
# Sample shape will be [3, 4, 3, 4, 2]
binomial_samples = tf.random.stateless_binomial(
shape=shape, seed=[123, 456], counts=counts, probs=probs)
Args |
shape
|
A 1-D integer Tensor or Python array. The shape of the output tensor.
|
seed
|
A shape [2] integer Tensor of seeds to the random number generator.
|
counts
|
Tensor. The counts of the binomial distribution. Must be
broadcastable with probs , and broadcastable with the rightmost
dimensions of shape .
|
probs
|
Tensor. The probability of success for the binomial distribution.
Must be broadcastable with counts and broadcastable with the rightmost
dimensions of shape .
|
output_dtype
|
The type of the output. Default: tf.int32
|
name
|
A name for the operation (optional).
|
Returns |
samples
|
A Tensor of the specified shape filled with random binomial
values. For each i, each samples[..., i] is an independent draw from
the binomial distribution on counts[i] trials with probability of
success probs[i].
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-10-01 UTC.
[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.random.stateless_binomial\n\n\u003cbr /\u003e\n\n|---------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.2.0/tensorflow/python/ops/stateless_random_ops.py#L132-L197) |\n\nOutputs deterministic pseudorandom values from a binomial distribution.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.random.stateless_binomial`](/api_docs/python/tf/random/stateless_binomial)\n\n\u003cbr /\u003e\n\n tf.random.stateless_binomial(\n shape, seed, counts, probs, output_dtype=tf.dtypes.int32, name=None\n )\n\nThe generated values follow a binomial distribution with specified count and\nprobability of success parameters.\n\nThis is a stateless version of [`tf.random.Generator.binomial`](../../tf/random/Generator#binomial): if run twice\nwith the same seeds, it will produce the same pseudorandom numbers. The\noutput is consistent across multiple runs on the same hardware (and between\nCPU and GPU), but may change between versions of TensorFlow or on non-CPU/GPU\nhardware.\n\n#### Example:\n\n counts = [10., 20.]\n # Probability of success.\n probs = [0.8]\n\n binomial_samples = tf.random.stateless_binomial(\n shape=[2], seed=[123, 456], counts=counts, probs=probs)\n\n counts = ... # Shape [3, 1, 2]\n probs = ... # Shape [1, 4, 2]\n shape = [3, 4, 3, 4, 2]\n # Sample shape will be [3, 4, 3, 4, 2]\n binomial_samples = tf.random.stateless_binomial(\n shape=shape, seed=[123, 456], counts=counts, probs=probs)\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `shape` | A 1-D integer Tensor or Python array. The shape of the output tensor. |\n| `seed` | A shape \\[2\\] integer Tensor of seeds to the random number generator. |\n| `counts` | Tensor. The counts of the binomial distribution. Must be broadcastable with `probs`, and broadcastable with the rightmost dimensions of `shape`. |\n| `probs` | Tensor. The probability of success for the binomial distribution. Must be broadcastable with `counts` and broadcastable with the rightmost dimensions of `shape`. |\n| `output_dtype` | The type of the output. Default: tf.int32 |\n| `name` | A name for the operation (optional). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|-----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `samples` | A Tensor of the specified shape filled with random binomial values. For each i, each samples\\[..., i\\] is an independent draw from the binomial distribution on counts\\[i\\] trials with probability of success probs\\[i\\]. |\n\n\u003cbr /\u003e"]]