简体   繁体   中英

Tensorflow 2.x - tf.contrib.layers.variance_scaling_initializer()

I've problem with this line and using Tensorflow 2.3.1

if w_init is None:
        w_init = tf.contrib.layers.variance_scaling_initializer()

AttributeError: module 'tensorflow' has no attribute 'contrib'

tf.contrib was removed from tf2.0. When migrating code from tf1.0 it's probably one of the only few things that have to be changed. However, you can find the underlying modules elsewhere. Example here .

if w_init is None:
        w_init = tf.keras.initializers.variance_scaling()

Do go through this official documentation on how to migrate from tf1.0 to tf2.0 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM