Tensorflow 1.2.1:AttributeError:模块'tensorflow'没有属性'random'

问题描述

我已经安装了tensorflow 1.2.1,并且每当我尝试运行时

c=tf.random.normal(shape=(3,4),dtype=tf.float32)

我收到错误AttributeError: module 'tensorflow' has no attribute 'random'

解决方法

使用

c = tf.random_normal(shape=(3,4),dtype=tf.float32))

查看可用API的完整列表here

查看用法here