tensorflow 2.1.0: has no attribute 'random_normal'

Question:

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]

Would appreciate help re how to get past this error.

Asked By: Sol

||

Answers:

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

Answered By: GPhilo

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

Answered By: Lakshmikandan

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

Answered By: Sohag Kumar Mondal
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.