简体   繁体   中英

TensorFlow - tf.layers vs tf.contrib.layers

In TensorFlow, tf.layers and tf.contrib.layers share a lot of functionality (standard 2D convolutional layers, batch normalization layers, etc). Is the difference between these two just that the contrib.layers package is still experimental where the layers package is considered stable? Or is one being replaced by the other? Other differences? Why are these two separate?

You've answered your own question. The description on the official documentation for the tf.contrib namespace is:

contrib module containing volatile or experimental code.

So tf.contrib is reserved for experimental features. APIs in this namespace are allowed to change rapidly between versions, whereas the others usually can't without a new major version. In particular, the functions in tf.contrib.layers are not identical to those found in tf.layers , although some of them might be replicated with different names.

As for whether you should use them, that depends on whether you are willing to handle sudden breaking changes. Code that doesn't rely on tf.contrib may be easier to migrate to future versions of TensorFlow.

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