报错提示
报错图片:
报错信息:
AttributeError: module ‘tensorflow’ has no attribute ‘random_shuffle’
出错原因
显示tf没有random_shuffle属性,mask-rcnn源码为tf 1.3版本,本机是tensorflow 2.2.0环境,tf2弃用了tf1很多函数,在model.py、utils.py、parallel_model.py等文件(所有需要import tensorflow的文件中均做此修改)中
https://blog.csdn.net/u013085021/article/details/108082875
解决方法
方法一:
将
import tensorflow as tf
修改为:
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
方法二:
我在使用第一个方法过程中,遇到无法解析情况,如下图:
于是使用了方法二:
代码段:
import tensorflow._api.v2.compat.v1 as tf
tf.disable_v2_behavior()
参考链接
链接1:https://blog.csdn.net/u013085021/article/details/108082875
链接2:https://blog.csdn.net/weixin_45647721/article/details/124840031?ops_request_misc=&request_id=&biz_id=102&utm_term=Import%20%22tensorflow.compat.v1%22%20&utm_medium=distribute.pc_search_result.none-task-blog-2blogsobaiduweb~default-0-124840031.142v42pc_ran_alice,185v2control&spm=1018.2226.3001.4450