tf.random.stateless_parameterized_truncated_normal
Stay organized with collections
Save and categorize content based on your preferences.
Outputs random values from a truncated normal distribution.
tf.random.stateless_parameterized_truncated_normal(
shape, seed, means=0.0, stddevs=1.0, minvals=-2.0, maxvals=2.0, name=None
)
The generated values follow a normal distribution with specified mean and
standard deviation, except that values whose magnitude is more than 2 standard
deviations from the mean are dropped and re-picked.
Examples:
Sample from a Truncated normal, with deferring shape parameters that
broadcast.
means = 0.
stddevs = tf.math.exp(tf.random.uniform(shape=[2, 3]))
minvals = [-1., -2., -1000.]
maxvals = [[10000.], [1.]]
y = tf.random.stateless_parameterized_truncated_normal(
shape=[10, 2, 3], seed=[7, 17],
means=means, stddevs=stddevs, minvals=minvals, maxvals=maxvals)
y.shape
TensorShape([10, 2, 3])
Args |
shape
|
A 1-D integer Tensor or Python array. The shape of the output
tensor.
|
seed
|
A shape [2] Tensor, the seed to the random number generator. Must have
dtype int32 or int64 . (When using XLA, only int32 is allowed.)
|
means
|
A Tensor or Python value of type dtype . The mean of the truncated
normal distribution. This must broadcast with stddevs , minvals and
maxvals , and the broadcasted shape must be dominated by shape .
|
stddevs
|
A Tensor or Python value of type dtype . The standard deviation
of the truncated normal distribution. This must broadcast with means ,
minvals and maxvals , and the broadcasted shape must be dominated by
shape .
|
minvals
|
A Tensor or Python value of type dtype . The minimum value of
the truncated normal distribution. This must broadcast with means ,
stddevs and maxvals , and the broadcasted shape must be dominated by
shape .
|
maxvals
|
A Tensor or Python value of type dtype . The maximum value of
the truncated normal distribution. This must broadcast with means ,
stddevs and minvals , and the broadcasted shape must be dominated by
shape .
|
name
|
A name for the operation (optional).
|
Returns |
A tensor of the specified shape filled with random truncated normal values.
|
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. Some content is licensed under the numpy license.
Last updated 2024-04-26 UTC.
[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tf.random.stateless_parameterized_truncated_normal\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/ops/stateless_random_ops.py#L850-L921) |\n\nOutputs random values from a truncated normal 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_parameterized_truncated_normal`](https://www.tensorflow.org/api_docs/python/tf/random/stateless_parameterized_truncated_normal)\n\n\u003cbr /\u003e\n\n tf.random.stateless_parameterized_truncated_normal(\n shape, seed, means=0.0, stddevs=1.0, minvals=-2.0, maxvals=2.0, name=None\n )\n\nThe generated values follow a normal distribution with specified mean and\nstandard deviation, except that values whose magnitude is more than 2 standard\ndeviations from the mean are dropped and re-picked.\n\n#### Examples:\n\nSample from a Truncated normal, with deferring shape parameters that\nbroadcast. \n\n means = 0.\n stddevs = tf.math.exp(tf.random.uniform(shape=[2, 3]))\n minvals = [-1., -2., -1000.]\n maxvals = [[10000.], [1.]]\n y = tf.random.stateless_parameterized_truncated_normal(\n shape=[10, 2, 3], seed=[7, 17],\n means=means, stddevs=stddevs, minvals=minvals, maxvals=maxvals)\n y.shape\n TensorShape([10, 2, 3])\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\\] Tensor, the seed to the random number generator. Must have dtype `int32` or `int64`. (When using XLA, only `int32` is allowed.) |\n| `means` | A `Tensor` or Python value of type `dtype`. The mean of the truncated normal distribution. This must broadcast with `stddevs`, `minvals` and `maxvals`, and the broadcasted shape must be dominated by `shape`. |\n| `stddevs` | A `Tensor` or Python value of type `dtype`. The standard deviation of the truncated normal distribution. This must broadcast with `means`, `minvals` and `maxvals`, and the broadcasted shape must be dominated by `shape`. |\n| `minvals` | A `Tensor` or Python value of type `dtype`. The minimum value of the truncated normal distribution. This must broadcast with `means`, `stddevs` and `maxvals`, and the broadcasted shape must be dominated by `shape`. |\n| `maxvals` | A `Tensor` or Python value of type `dtype`. The maximum value of the truncated normal distribution. This must broadcast with `means`, `stddevs` and `minvals`, and the broadcasted shape must be dominated by `shape`. |\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| A tensor of the specified shape filled with random truncated normal values. ||\n\n\u003cbr /\u003e"]]