首页 > 其他分享 >AttributeError: module 'tensorflow._api.v1.random' has no attribute 'set_seed'

AttributeError: module 'tensorflow._api.v1.random' has no attribute 'set_seed'

时间:2023-02-15 23:44:06浏览次数:35  
标签:set no attribute random module seed ._ AttributeError

 

 
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_23207/1672961205.py in <module>
     18 np.random.seed(7)
     19 np.random.shuffle(y_train)
---> 20 tf.random.set_seed(7)
     21 
     22 # 使x_train 数]。

/home/software/anaconda3/envs/tf115/lib/python3.7/site-packages/tensorflow_core/python/util/module_wrapper.py in __getattr__(self, name)
    191   def __getattr__(self, name):
    192     try:
--> 193       attr = getattr(self._tfmw_wrapped_module, name)
    194     except AttributeError:
    195       if not self._tfmw_public_apis:

AttributeError: module 'tensorflow._api.v1.random' has no attribute 'set_seed'

 

解决方法:

set_seed() 改为  set_random_seed() ,  tf2 才有 set_seed()。

 

标签:set,no,attribute,random,module,seed,._,AttributeError
From: https://www.cnblogs.com/emanlee/p/17125177.html

相关文章