简体   繁体   English

Tensorflow 2 中的 tf.contrib.layers.fully_connected()?

[英]tf.contrib.layers.fully_connected() in Tensorflow 2?

I'm trying to use tf.contrib.layers.fully_connected() in one of my projects, and it's been deprecated in tensorflow 2.0.我正在尝试在我的一个项目中使用 tf.contrib.layers.fully_connected() ,它在 tensorflow 2.0 中已被弃用。 Is there an equivalent function, or should I just keep tensorflow v1.x in my virtual environment for this projcet?是否有等效的 function,或者我应该在我的虚拟环境中为这个项目保留 tensorflow v1.x?

tf-slim, as a standalone package, already included tf.contrib.layers.you can install by pip install tf-slim ,call it by from tf_slim.layers import layers as _layers; _layers.fully_conntected(..) tf-slim,作为一个独立的 package,已经包含了 tf.contrib.layers。你可以通过pip install tf-slim ,调用它from tf_slim.layers import layers as _layers; _layers.fully_conntected(..) from tf_slim.layers import layers as _layers; _layers.fully_conntected(..) .The same as the original, easy to replace from tf_slim.layers import layers as _layers; _layers.fully_conntected(..) .和原来一样,替换方便

In TensorFlow 2.0 the package tf.contrib has been removed (and this was a good choice since the whole package was a huge mix of different projects all placed inside the same box), so you can't use it.在 TensorFlow 2.0 中,package tf.contrib已被删除(这是一个不错的选择,因为整个 ZEFE90A8E604A7C840E88D03A67F6t 都使用 B7D8Z 是一个巨大的组合)

In TensorFlow 2.0 we need to use tf.keras.layers.Dense to create a fully connected layer, but more importantly, you have to migrate your codebase to Keras.在 TensorFlow 2.0 中我们需要使用tf.keras.layers.Dense来创建一个全连接层,但更重要的是,您必须将代码库迁移到 Z7FEE7BB66F4294C3E32783EFA7D9FCBA In fact, you can't define a layer and use it, without creating a tf.keras.Model object that uses it.事实上,如果不创建使用它的tf.keras.Model object,就无法定义层并使用它。

tf.contrib.layers.fully_connected() is a perfect mess. tf.contrib.layers.fully_connected() 是一团糟。 It is a very old historical mark(or a prehistory DNN legacy).这是一个非常古老的历史标记(或史前 DNN 遗产)。 Google has completely deprecated the function since Google hated it.谷歌已经完全弃用了 function,因为谷歌讨厌它。 There is no any direct function in TensoFlow 2.x to replace tf.contrib.layers.fully_connected(). TensoFlow 2.x 中没有任何直接的 function 来替换 tf.contrib.layers.fully_connected()。 Therefore, it is not worth inquiring and getting to know the function.因此,function不值得查询和了解。

use: tf.compat.v1.layers.dense for example, instead of使用: tf.compat.v1.layers.dense例如,而不是

Z = tf.contrib.layers.fully_connected(F, num_outputs, activation_fn=None)

you can replace it with:您可以将其替换为:

Z = tf.compat.v1.layers.dense(F, num_outputs, activation = None)

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

相关问题 tf.contrib.layers.fully_connected()行为是否会在tensorflow 1.3和1.4之间发生变化? - Is tf.contrib.layers.fully_connected() behavior change between tensorflow 1.3 and 1.4 an issue? Tensorflow2.0:`tf.contrib.layers.fully_connected` 的替代品是什么? - Tensorflow2.0: What is the replacement of `tf.contrib.layers.fully_connected`? 如何从tf.contrib.layers.fully_connected()中提取名称 - How to extract name from tf.contrib.layers.fully_connected() 如何从使用 tf.contrib.layers.fully_connected 创建的层访问权重? - How can I access weights from a layer created with tf.contrib.layers.fully_connected? tf.contrib.layer.fully_connected, tf.layers.dense, tf.contrib.slim.fully_connected, tf.keras.layers.Dense 之间的不一致 - Inconsistencies between tf.contrib.layer.fully_connected, tf.layers.dense, tf.contrib.slim.fully_connected, tf.keras.layers.Dense TensorFlow - tf.layers vs tf.contrib.layers - TensorFlow - tf.layers vs tf.contrib.layers Tensorflow:tf.contrib.layers.embed_sequence - Tensorflow: tf.contrib.layers.embed_sequence Tensorflow:将手动构建图层转换为tf.contrib.layers - Tensorflow: Transforming manually build layers to tf.contrib.layers 将层连接到完全连接的层Tensorflow - concatenate layers to a fully connected layer Tensorflow 张量流完全连接的层之间的差异 - Difference between different tensorflow fully connected layers
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM