MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / random_uniform_variable

Function random_uniform_variable

tensorflow/python/keras/backend.py:1439–1472  ·  view source on GitHub ↗

Instantiates a variable with values drawn from a uniform distribution. Arguments: shape: Tuple of integers, shape of returned Keras variable. low: Float, lower boundary of the output interval. high: Float, upper boundary of the output interval. dtype: String, dtype of retu

(shape, low, high, dtype=None, name=None, seed=None)

Source from the content-addressed store, hash-verified

1437
1438@keras_export('keras.backend.random_uniform_variable')
1439def random_uniform_variable(shape, low, high, dtype=None, name=None, seed=None):
1440 """Instantiates a variable with values drawn from a uniform distribution.
1441
1442 Arguments:
1443 shape: Tuple of integers, shape of returned Keras variable.
1444 low: Float, lower boundary of the output interval.
1445 high: Float, upper boundary of the output interval.
1446 dtype: String, dtype of returned Keras variable.
1447 name: String, name of returned Keras variable.
1448 seed: Integer, random seed.
1449
1450 Returns:
1451 A Keras variable, filled with drawn samples.
1452
1453 Example:
1454 ```python
1455 # TensorFlow example
1456 >>> kvar = K.random_uniform_variable((2,3), 0, 1)
1457 >>> kvar
1458 <tensorflow.python.ops.variables.Variable object at 0x10ab40b10>
1459 >>> K.eval(kvar)
1460 array([[ 0.10940075, 0.10047495, 0.476143 ],
1461 [ 0.66137183, 0.00869417, 0.89220798]], dtype=float32)
1462 ```
1463 """
1464 if dtype is None:
1465 dtype = floatx()
1466 tf_dtype = dtypes_module.as_dtype(dtype)
1467 if seed is None:
1468 # ensure that randomness is conditioned by the Numpy RNG
1469 seed = np.random.randint(10e8)
1470 value = init_ops.random_uniform_initializer(
1471 low, high, dtype=tf_dtype, seed=seed)(shape)
1472 return variable(value, dtype=dtype, name=name)
1473
1474
1475@keras_export('keras.backend.random_normal_variable')

Callers

nothing calls this directly

Calls 2

floatxFunction · 0.85
variableFunction · 0.70

Tested by

no test coverage detected