简体   繁体   English

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

[英]Tensorflow 2.x - tf.contrib.layers.variance_scaling_initializer()

I've problem with this line and using Tensorflow 2.3.1我对这条线有问题并使用 Tensorflow 2.3.1

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

AttributeError: module 'tensorflow' has no attribute 'contrib' AttributeError:模块“tensorflow”没有属性“contrib”

tf.contrib was removed from tf2.0. tf.contrib已从 tf2.0 中删除。 When migrating code from tf1.0 it's probably one of the only few things that have to be changed.当从 tf1.0 迁移代码时,它可能是少数必须更改的事情之一。 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 .通过这个关于如何从 tf1.0 迁移到 tf2.0 的官方文档做 go

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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