tf.layers.dense() 和 tf.contrib.layers.fully_connected() 是否可以互换? [英] Are tf.layers.dense() and tf.contrib.layers.fully_connected() interchangeable?
问题描述
我习惯使用 tf.contrib.layers.fully_connected 来构建全连接层.最近我遇到了 tf.layers.dense 显然用于第一个功能可以使用的地方.是否可以互换,产生相同的输出?
I am used to using tf.contrib.layers.fully_connected to build a fully connected layer. Recently I ran into tf.layers.dense apparently used where the first functioned could be used. Are the interchangeable, producing the same output?
推荐答案
本质上是一样的,后者调用前者.
然而,tf.contrib.fully_connected
在 dense
之上添加了一些功能,特别是在参数中传递规范化和激活的可能性,à la Keras.正如@wordforthewise 所指出的,请注意后者默认为 tf.nn.relu
.
However tf.contrib.fully_connected
adds a few functionalities on top of dense
, in particular the possibility to pass a normalization and an activation in the parameters, à la Keras. As noted by @wordforthewise, mind that the later defaults to tf.nn.relu
.
更一般地说,TF API 提出了(并且有些令人困惑地混合)低级和高级 API;在此处了解更多信息.
More generally, the TF API proposes (and mixes somewhat confusingly) low- and hi-level APIs; more on that here.
这篇关于tf.layers.dense() 和 tf.contrib.layers.fully_connected() 是否可以互换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!