tensorflow2.0 解决ModuleNotFoundError: No module named ‘tensorflow.contrib‘

tensorflow2.0 解决ModuleNotFoundError: No module named ‘tensorflow.contrib.layers import xavier_initializer_conv2d’

代码

weights = tf.get_variable(shape=[filter_size, filter_size, channel_in, channel_out], dtype=tf.float32,
                                  initializer=xavier_initializer_conv2d(), name=scope + 'weights')

报错信息

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
 in ()
      4 #     pass
      5     ###
----> 6 from tensorflow.contrib.layers import xavier_initializer_conv2d
      7 from tensorflow.contrib.layers import flatten
      8 

ModuleNotFoundError: No module named 'tensorflow.contrib'

解决方法


initializer = tf.keras.initializers.glorot_normal

==使用tf.keras.initializers.glorot_normal替换xavier_initializer_conv2d() ==

你可能感兴趣的:(日常报错,tensorflow,python,深度学习,bug)