27

I'm trying to get Uber's Ludwig to run. I get an error about there being no attribute 'random_normal'. I can reproduce the error in Python with these commands.

>>> import tensorflow as tf
>>> tf.reduce_sum(tf.random_normal([1000,1000]))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'tensorflow' has no attribute 'random_normal'
>>> print(tf.__version__)
2.1.0
>>> print(sys.version)
3.7.5 (defaut, Oct 25 2019, 15:51:11)
[GCC 7.3.0]

How can I get past this error?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Sol
  • 985
  • 2
  • 10
  • 20
  • 3
    It was moved to `tf.random.normal` (as literally the first google result searching "tensorflow random_normal" shows...) – GPhilo Jan 28 '20 at 16:32
  • 2
    Ah, missed the underscore changing to period. Go ahead and create an answer if you like and I'll mark it as the best one. – Sol Jan 28 '20 at 16:38
  • @GPhilo this is the first google result – Rainb Jun 25 '20 at 18:08
  • @Rainb Now, it may be. On Jan 28, it wasn't :) – GPhilo Jun 25 '20 at 19:04
  • Did it actually output "defaut"? Or is it a [transcription error](https://en.wiktionary.org/wiki/default#Noun)? I currently get "`Python 3.6.9 (default, Mar 10 2023, 16:46:00)`" – Peter Mortensen May 24 '23 at 15:27

3 Answers3

47

It was moved to tf.random.normal (along with all the other tf.random_* functions)

GPhilo
  • 18,519
  • 9
  • 63
  • 89
7

TensorFlow 2.0 comes with new aliases for random_normal. Using tf.random.normal instead of tf.random_normal should execute successfully.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Lakshmikandan
  • 4,301
  • 3
  • 28
  • 37
0

Use this method. tf.reduce_sum(tf.compat.v1.random_normal([1000,1000]))

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 21 '22 at 16:18