beta
functionkeras.random.beta(shape, alpha, beta, dtype=None, seed=None)
Draw samples from a Beta distribution.
The values are drawn from a Beta distribution parametrized by alpha and beta.
Arguments
beta
and shape
.alpha
and shape
.keras.config.floatx()
is used,
which defaults to float32
unless you configured it otherwise (via
keras.config.set_floatx(float_dtype)
).keras.random.SeedGenerator
.
By default, the seed
argument is None
, and an internal global
keras.random.SeedGenerator
is used. The seed
argument can be
used to ensure deterministic (repeatable) random number generation.
Note that passing an integer as the seed
value will produce the
same random values for each call. To generate different random
values for repeated calls, an instance of
keras.random.SeedGenerator
must be provided as the seed
value.
Remark concerning the JAX backend: When tracing functions with the
JAX backend the global keras.random.SeedGenerator
is not
supported. Therefore, during tracing the default value seed=None
will produce an error, and a seed
argument must be provided.binomial
functionkeras.random.binomial(shape, counts, probabilities, dtype=None, seed=None)
Draw samples from a Binomial distribution.
The values are drawn from a Binomial distribution with specified trial count and probability of success.
Arguments
probabilities
.counts
.keras.config.floatx()
is used,
which defaults to float32
unless you configured it otherwise (via
keras.config.set_floatx(float_dtype)
).keras.random.SeedGenerator
.
By default, the seed
argument is None
, and an internal global
keras.random.SeedGenerator
is used. The seed
argument can be
used to ensure deterministic (repeatable) random number generation.
Note that passing an integer as the seed
value will produce the
same random values for each call. To generate different random
values for repeated calls, an instance of
keras.random.SeedGenerator
must be provided as the seed
value.
Remark concerning the JAX backend: When tracing functions with the
JAX backend the global keras.random.SeedGenerator
is not
supported. Therefore, during tracing the default value seed=None
will produce an error, and a seed
argument must be provided.categorical
functionkeras.random.categorical(logits, num_samples, dtype="int32", seed=None)
Draws samples from a categorical distribution.
This function takes as input logits
, a 2-D input tensor with shape
(batch_size, num_classes). Each row of the input represents a categorical
distribution, with each column index containing the log-probability for a
given class.
The function will output a 2-D tensor with shape (batch_size, num_samples),
where each row contains samples from the corresponding row in logits
.
Each column index contains an independent samples drawn from the input
distribution.
Arguments
keras.random.SeedGenerator
.
By default, the seed
argument is None
, and an internal global
keras.random.SeedGenerator
is used. The seed
argument can be
used to ensure deterministic (repeatable) random number generation.
Note that passing an integer as the seed
value will produce the
same random values for each call. To generate different random
values for repeated calls, an instance of
keras.random.SeedGenerator
must be provided as the seed
value.
Remark concerning the JAX backend: When tracing functions with the
JAX backend the global keras.random.SeedGenerator
is not
supported. Therefore, during tracing the default value seed=None
will produce an error, and a seed
argument must be provided.Returns
A 2-D tensor with (batch_size, num_samples).
dropout
functionkeras.random.dropout(inputs, rate, noise_shape=None, seed=None)
gamma
functionkeras.random.gamma(shape, alpha, dtype=None, seed=None)
Draw random samples from the Gamma distribution.
Arguments
keras.config.floatx()
is used,
which defaults to float32
unless you configured it otherwise (via
keras.config.set_floatx(float_dtype)
).keras.random.SeedGenerator
.
By default, the seed
argument is None
, and an internal global
keras.random.SeedGenerator
is used. The seed
argument can be
used to ensure deterministic (repeatable) random number generation.
Note that passing an integer as the seed
value will produce the
same random values for each call. To generate different random
values for repeated calls, an instance of
keras.random.SeedGenerator
must be provided as the seed
value.
Remark concerning the JAX backend: When tracing functions with the
JAX backend the global keras.random.SeedGenerator
is not
supported. Therefore, during tracing the default value seed=None
will produce an error, and a seed
argument must be provided.normal
functionkeras.random.normal(shape, mean=0.0, stddev=1.0, dtype=None, seed=None)
Draw random samples from a normal (Gaussian) distribution.
Arguments
keras.config.floatx()
is used,
which defaults to float32
unless you configured it otherwise (via
keras.config.set_floatx(float_dtype)
).keras.random.SeedGenerator
.
By default, the seed
argument is None
, and an internal global
keras.random.SeedGenerator
is used. The seed
argument can be
used to ensure deterministic (repeatable) random number generation.
Note that passing an integer as the seed
value will produce the
same random values for each call. To generate different random
values for repeated calls, an instance of
keras.random.SeedGenerator
must be provided as the seed
value.
Remark concerning the JAX backend: When tracing functions with the
JAX backend the global keras.random.SeedGenerator
is not
supported. Therefore, during tracing the default value seed=None
will produce an error, and a seed
argument must be provided.randint
functionkeras.random.randint(shape, minval, maxval, dtype="int32", seed=None)
Draw random integers from a uniform distribution.
The generated values follow a uniform distribution in the range
[minval, maxval)
. The lower bound minval
is included in the range,
while the upper bound maxval
is excluded.
dtype
must be an integer type.
Arguments
keras.config.floatx()
is used,
which defaults to float32
unless you configured it otherwise (via
keras.config.set_floatx(float_dtype)
)keras.random.SeedGenerator
.
By default, the seed
argument is None
, and an internal global
keras.random.SeedGenerator
is used. The seed
argument can be
used to ensure deterministic (repeatable) random number generation.
Note that passing an integer as the seed
value will produce the
same random values for each call. To generate different random
values for repeated calls, an instance of
keras.random.SeedGenerator
must be provided as the seed
value.
Remark concerning the JAX backend: When tracing functions with the
JAX backend the global keras.random.SeedGenerator
is not
supported. Therefore, during tracing the default value seed=None
will produce an error, and a seed
argument must be provided.shuffle
functionkeras.random.shuffle(x, axis=0, seed=None)
Shuffle the elements of a tensor uniformly at random along an axis.
Arguments
0
.keras.random.SeedGenerator
.
By default, the seed
argument is None
, and an internal global
keras.random.SeedGenerator
is used. The seed
argument can be
used to ensure deterministic (repeatable) random number generation.
Note that passing an integer as the seed
value will produce the
same random values for each call. To generate different random
values for repeated calls, an instance of
keras.random.SeedGenerator
must be provided as the seed
value.
Remark concerning the JAX backend: When tracing functions with the
JAX backend the global keras.random.SeedGenerator
is not
supported. Therefore, during tracing the default value seed=None
will produce an error, and a seed
argument must be provided.truncated_normal
functionkeras.random.truncated_normal(shape, mean=0.0, stddev=1.0, dtype=None, seed=None)
Draw samples from a truncated normal distribution.
The values are drawn from a normal distribution with specified mean and standard deviation, discarding and re-drawing any samples that are more than two standard deviations from the mean.
Arguments
keras.config.floatx()
is used,
which defaults to float32
unless you configured it otherwise (via
keras.config.set_floatx(float_dtype)
)keras.random.SeedGenerator
.
By default, the seed
argument is None
, and an internal global
keras.random.SeedGenerator
is used. The seed
argument can be
used to ensure deterministic (repeatable) random number generation.
Note that passing an integer as the seed
value will produce the
same random values for each call. To generate different random
values for repeated calls, an instance of
keras.random.SeedGenerator
must be provided as the seed
value.
Remark concerning the JAX backend: When tracing functions with the
JAX backend the global keras.random.SeedGenerator
is not
supported. Therefore, during tracing the default value seed=None
will produce an error, and a seed
argument must be provided.uniform
functionkeras.random.uniform(shape, minval=0.0, maxval=1.0, dtype=None, seed=None)
Draw samples from a uniform distribution.
The generated values follow a uniform distribution in the range
[minval, maxval)
. The lower bound minval
is included in the range,
while the upper bound maxval
is excluded.
dtype
must be a floating point type, the default range is [0, 1)
.
Arguments
keras.config.floatx()
is used,
which defaults to float32
unless you configured it otherwise (via
keras.config.set_floatx(float_dtype)
)keras.random.SeedGenerator
.
By default, the seed
argument is None
, and an internal global
keras.random.SeedGenerator
is used. The seed
argument can be
used to ensure deterministic (repeatable) random number generation.
Note that passing an integer as the seed
value will produce the
same random values for each call. To generate different random
values for repeated calls, an instance of
keras.random.SeedGenerator
must be provided as the seed
value.
Remark concerning the JAX backend: When tracing functions with the
JAX backend the global keras.random.SeedGenerator
is not
supported. Therefore, during tracing the default value seed=None
will produce an error, and a seed
argument must be provided.