TensorFlow - tf.layers 与 tf.contrib.layers [英] TensorFlow - tf.layers vs tf.contrib.layers

查看:29
本文介绍了TensorFlow - tf.layers 与 tf.contrib.layers的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 TensorFlow 中,tf.layerstf.contrib.layers 分享了很多功能(标准 2D 卷积层、批量归一化层等).这两者之间的区别仅仅是 contrib.layers 包仍然是实验性的,而 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?

推荐答案

您已经回答了自己的问题.tf.contrib 命名空间是:

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

包含易失性或实验性代码的 contrib 模块.

contrib module containing volatile or experimental code.

所以 tf.contrib 是为实验性功能保留的.此命名空间中的 API 可以在版本之间快速更改,而其他 API 通常不能没有新的主要版本.特别是,tf.contrib.layers 中的函数与 tf.layers 中的函数不同,尽管其中一些可能以不同的名称复制.

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.

至于是否应该使用它们,这取决于您是否愿意处理突然的破坏性变化.不依赖于 tf.contrib 的代码可能更容易迁移到 TensorFlow 的未来版本.

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.

这篇关于TensorFlow - tf.layers 与 tf.contrib.layers的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆