FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Raise ValueError if invalid dtype for random_uniform. · codeplaysoftware/tensorflow@aee5dcc · GitHub

Repository navigation

Commit aee5dcc

Browse files
authored andcommitted
Raise ValueError if invalid dtype for random_uniform.
PiperOrigin-RevId: 159764956
1 parent eb00d1d commit aee5dcc

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎tensorflow/python/ops/random_ops.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ def random_uniform(shape,
206206
maxval: A 0-D Tensor or Python value of type `dtype`. The upper bound on
207207
the range of random values to generate. Defaults to 1 if `dtype` is
208208
floating point.
209-
dtype: The type of the output: `float32`, `float64`, `int32`, or `int64`.
209+
dtype: The type of the output: 'float16`, `float32`, `float64`, `int32`,
210+
or `int64`.
210211
seed: A Python integer. Used to create a random seed for the distribution.
211212
See @{tf.set_random_seed}
212213
for behavior.
@@ -219,6 +220,9 @@ def random_uniform(shape,
219220
ValueError: If `dtype` is integral and `maxval` is not specified.
220221
"""
221222
dtype = dtypes.as_dtype(dtype)
223+
if dtype not in (dtypes.float16, dtypes.float32, dtypes.float64, dtypes.int32,
224+
dtypes.int64):
225+
raise ValueError("Invalid dtype %r" % dtype)
222226
if maxval is None:
223227
if dtype.is_integer:
224228
raise ValueError("Must specify maxval for integer dtype %r" % dtype)

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL