draw random samples from a normal gaussian distribution args shape the shape of the random values to generate mean float defaults to 0 mean of the random values to generate stddev float defaults to 1 standard deviation of the random values to generate dtype optional dtype of the tensor only floating point types are supported if not specified keras config floatx is used which defaults to float32 unless you configured it otherwise via keras config setfloatxfloatdtype seed a python integer or instance of keras random seedgenerator used to make the behavior of the initializer deterministic note that an initializer seeded with an integer or none unseeded will produce the same random values across multiple calls to get different random values across multiple calls use as seed an instance of keras random seedgenerator draws samples from a categorical distribution this function takes as input logits a 2d input tensor with shape batchsize numclasses each row of the input represents a categorical distribution with each column index containing the logprobability for a given class the function will output a 2d tensor with shape batchsize numsamples where each row contains samples from the corresponding row in logits each column index contains an independent samples drawn from the input distribution args logits 2d tensor with shape batchsize numclasses each row should define a categorical distibution with the unnormalized logprobabilities for all classes numsamples int the number of independent samples to draw for each row of the input this will be the second dimension of the output tensor s shape dtype optional dtype of the output tensor seed a python integer or instance of keras random seedgenerator used to make the behavior of the initializer deterministic note that an initializer seeded with an integer or none unseeded will produce the same random values across multiple calls to get different random values across multiple calls use as seed an instance of keras random seedgenerator returns a 2d tensor with batchsize numsamples 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 args shape the shape of the random values to generate minval float defaults to 0 lower bound of the range of random values to generate inclusive maxval float defaults to 1 upper bound of the range of random values to generate exclusive dtype optional dtype of the tensor only floating point types are supported if not specified keras config floatx is used which defaults to float32 unless you configured it otherwise via keras config setfloatxfloatdtype seed a python integer or instance of keras random seedgenerator used to make the behavior of the initializer deterministic note that an initializer seeded with an integer or none unseeded will produce the same random values across multiple calls to get different random values across multiple calls use as seed an instance of keras random seedgenerator 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 args shape the shape of the random values to generate minval float defaults to 0 lower bound of the range of random values to generate inclusive maxval float defaults to 1 upper bound of the range of random values to generate exclusive dtype optional dtype of the tensor only integer types are supported if not specified keras config floatx is used which defaults to float32 unless you configured it otherwise via keras config setfloatxfloatdtype seed a python integer or instance of keras random seedgenerator used to make the behavior of the initializer deterministic note that an initializer seeded with an integer or none unseeded will produce the same random values across multiple calls to get different random values across multiple calls use as seed an instance of keras random seedgenerator draw samples from a truncated normal distribution the values are drawn from a normal distribution with specified mean and standard deviation discarding and redrawing any samples that are more than two standard deviations from the mean args shape the shape of the random values to generate mean float defaults to 0 mean of the random values to generate stddev float defaults to 1 standard deviation of the random values to generate dtype optional dtype of the tensor only floating point types are supported if not specified keras config floatx is used which defaults to float32 unless you configured it otherwise via keras config setfloatxfloatdtype seed a python integer or instance of keras random seedgenerator used to make the behavior of the initializer deterministic note that an initializer seeded with an integer or none unseeded will produce the same random values across multiple calls to get different random values across multiple calls use as seed an instance of keras random seedgenerator shuffle the elements of a tensor uniformly at random along an axis args x the tensor to be shuffled axis an integer specifying the axis along which to shuffle defaults to 0 seed a python integer or instance of keras random seedgenerator used to make the behavior of the initializer deterministic note that an initializer seeded with an integer or none unseeded will produce the same random values across multiple calls to get different random values across multiple calls use as seed an instance of keras random seedgenerator draw random samples from the gamma distribution args shape the shape of the random values to generate alpha float the parameter of the distribution dtype optional dtype of the tensor only floating point types are supported if not specified keras config floatx is used which defaults to float32 unless you configured it otherwise via keras config setfloatxfloatdtype seed a python integer or instance of keras random seedgenerator used to make the behavior of the initializer deterministic note that an initializer seeded with an integer or none unseeded will produce the same random values across multiple calls to get different random values across multiple calls use as seed an instance of keras random seedgenerator draw random samples from a normal gaussian distribution args shape the shape of the random values to generate mean float defaults to 0 mean of the random values to generate stddev float defaults to 1 standard deviation of the random values to generate dtype optional dtype of the tensor only floating point types are supported if not specified keras config floatx is used which defaults to float32 unless you configured it otherwise via keras config set_floatx float_dtype seed a python integer or instance of keras random seedgenerator used to make the behavior of the initializer deterministic note that an initializer seeded with an integer or none unseeded will produce the same random values across multiple calls to get different random values across multiple calls use as seed an instance of keras random seedgenerator 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 args logits 2 d tensor with shape batch_size num_classes each row should define a categorical distibution with the unnormalized log probabilities for all classes num_samples int the number of independent samples to draw for each row of the input this will be the second dimension of the output tensor s shape dtype optional dtype of the output tensor seed a python integer or instance of keras random seedgenerator used to make the behavior of the initializer deterministic note that an initializer seeded with an integer or none unseeded will produce the same random values across multiple calls to get different random values across multiple calls use as seed an instance of keras random seedgenerator returns a 2 d tensor with batch_size num_samples 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 args shape the shape of the random values to generate minval float defaults to 0 lower bound of the range of random values to generate inclusive maxval float defaults to 1 upper bound of the range of random values to generate exclusive dtype optional dtype of the tensor only floating point types are supported if not specified keras config floatx is used which defaults to float32 unless you configured it otherwise via keras config set_floatx float_dtype seed a python integer or instance of keras random seedgenerator used to make the behavior of the initializer deterministic note that an initializer seeded with an integer or none unseeded will produce the same random values across multiple calls to get different random values across multiple calls use as seed an instance of keras random seedgenerator 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 args shape the shape of the random values to generate minval float defaults to 0 lower bound of the range of random values to generate inclusive maxval float defaults to 1 upper bound of the range of random values to generate exclusive dtype optional dtype of the tensor only integer types are supported if not specified keras config floatx is used which defaults to float32 unless you configured it otherwise via keras config set_floatx float_dtype seed a python integer or instance of keras random seedgenerator used to make the behavior of the initializer deterministic note that an initializer seeded with an integer or none unseeded will produce the same random values across multiple calls to get different random values across multiple calls use as seed an instance of keras random seedgenerator 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 args shape the shape of the random values to generate mean float defaults to 0 mean of the random values to generate stddev float defaults to 1 standard deviation of the random values to generate dtype optional dtype of the tensor only floating point types are supported if not specified keras config floatx is used which defaults to float32 unless you configured it otherwise via keras config set_floatx float_dtype seed a python integer or instance of keras random seedgenerator used to make the behavior of the initializer deterministic note that an initializer seeded with an integer or none unseeded will produce the same random values across multiple calls to get different random values across multiple calls use as seed an instance of keras random seedgenerator shuffle the elements of a tensor uniformly at random along an axis args x the tensor to be shuffled axis an integer specifying the axis along which to shuffle defaults to 0 seed a python integer or instance of keras random seedgenerator used to make the behavior of the initializer deterministic note that an initializer seeded with an integer or none unseeded will produce the same random values across multiple calls to get different random values across multiple calls use as seed an instance of keras random seedgenerator draw random samples from the gamma distribution args shape the shape of the random values to generate alpha float the parameter of the distribution dtype optional dtype of the tensor only floating point types are supported if not specified keras config floatx is used which defaults to float32 unless you configured it otherwise via keras config set_floatx float_dtype seed a python integer or instance of keras random seedgenerator used to make the behavior of the initializer deterministic note that an initializer seeded with an integer or none unseeded will produce the same random values across multiple calls to get different random values across multiple calls use as seed an instance of keras random seedgenerator
from keras import backend
from keras.api_export import keras_export


@keras_export("keras.random.normal")
def normal(shape, mean=0.0, stddev=1.0, dtype=None, seed=None):
    
    return backend.random.normal(
        shape, mean=mean, stddev=stddev, dtype=dtype, seed=seed
    )


@keras_export("keras.random.categorical")
def categorical(logits, num_samples, dtype="int32", seed=None):
    
    logits_shape = list(backend.convert_to_tensor(logits).shape)
    if len(logits_shape) != 2:
        raise ValueError(
            "`logits` should be a 2-D tensor with shape "
            f"[batch_size, num_classes]. Received: logits={logits}"
        )
    return backend.random.categorical(
        logits, num_samples, dtype=dtype, seed=seed
    )


@keras_export("keras.random.uniform")
def uniform(shape, minval=0.0, maxval=1.0, dtype=None, seed=None):
    
    if dtype and not backend.is_float_dtype(dtype):
        raise ValueError(
            "`keras.random.uniform` requires a floating point `dtype`. "
            f"Received: dtype={dtype} "
        )
    return backend.random.uniform(
        shape, minval=minval, maxval=maxval, dtype=dtype, seed=seed
    )


@keras_export("keras.random.randint")
def randint(shape, minval, maxval, dtype="int32", seed=None):
    
    if dtype and not backend.is_int_dtype(dtype):
        raise ValueError(
            "`keras.random.randint` requires an integer `dtype`. "
            f"Received: dtype={dtype} "
        )
    return backend.random.randint(
        shape, minval=minval, maxval=maxval, dtype=dtype, seed=seed
    )


@keras_export("keras.random.truncated_normal")
def truncated_normal(shape, mean=0.0, stddev=1.0, dtype=None, seed=None):
    
    return backend.random.truncated_normal(
        shape, mean=mean, stddev=stddev, dtype=dtype, seed=seed
    )


@keras_export("keras.random.dropout")
def dropout(inputs, rate, noise_shape=None, seed=None):
    return backend.random.dropout(
        inputs, rate, noise_shape=noise_shape, seed=seed
    )


@keras_export("keras.random.shuffle")
def shuffle(x, axis=0, seed=None):
    
    return backend.random.shuffle(x, axis=axis, seed=seed)


@keras_export("keras.random.gamma")
def gamma(shape, alpha, dtype=None, seed=None):
    
    return backend.random.gamma(shape, alpha=alpha, dtype=dtype, seed=seed)