tensorflow 2.1.0:没有属性“random_normal”

Sol*_*Sol 17 python tensorflow ludwig

我试图让 Uber 的 Ludwig 跑起来。我收到关于没有属性“random_normal”的错误。我可以使用这些命令在 Python 中重现错误。

>>> 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]
Run Code Online (Sandbox Code Playgroud)

非常感谢有关如何克服此错误的帮助。

GPh*_*ilo 39

它已移至tf.random.normal(以及所有其他tf.random_*功能)


lak*_*dan 7

TensorFlow 2.0 为 random_normal 提供了新的别名。使用tf.random.normal代替tf.random_normal应该可以成功执行。