weights_regularizer = tf.contrib.layers.l2_regularizer(cfg.FLAGS.weight_decay)
AttributeError: module 'tensorflow.compat.v1' has no attribute 'contrib'
l2_regularizer改怎么用,请尽量给出代码
tensorflow2.0将1.0的很多功能优化或去掉了,建议降低tensorflow版本
TensorFlow2.0之后的版本删掉了l2正则化函数tf.contrib.layers.l2_regularizer所以报错
解决方法可以参考:https://blog.csdn.net/maple05/article/details/108186303