0

I'm learning TensorFlow 2.0. I'm trying to use the function or method

uniform = tf.random.uniform(shape=(5), minval=5, maxval=10)

but Python throws this error:

Truncated Traceback (Use C-c C-$ to view full TB):
/usr/lib/python3.7/site-packages/six.py in raise_from(value, from_value)

InvalidArgumentError: shape must be a vector of {int32,int64}, got shape [] [Op:RandomUniform]

When I try to execute this line using shape=[5], it executes without problem. It's a TensorFlow problem, or I'm not understanding something?

jdehesa
  • 58,456
  • 7
  • 77
  • 121
class_OpenGL
  • 185
  • 1
  • 10
  • 2
    `(5)` is the same as `5`, you need to give a list or a tuple (or a tensor) as a shape, if you want to make a one-element tuple you need to write `(5,)`. – jdehesa Aug 29 '19 at 14:14
  • Thank you for your fast answer. I'm ashamed. I have to learn a lot of Python. Thanks a lot – class_OpenGL Aug 29 '19 at 14:15
  • 2
    No reason to be ashamed, it's actually a very common mistake (one of the less nice aspects of Python's syntax), and learning is the whole point of this site anyway! – jdehesa Aug 29 '19 at 14:24

0 Answers0