tensorflow - 为什么 slim.nets.vgg 使用 conv2d 而不是全连接层?

标签 tensorflow

在 tensorflow/models/slim/nets 中,这里是 vgg 的相关片段的链接.我很好奇为什么 slim.nets.vgg 使用 conv2d 而不是fully_connected 层,尽管实际上它的工作方式相同?是为了速度吗?
我很欣赏一些解释。谢谢!

最佳答案

一段时间后,我认为至少有一个原因可以避免权重转换错误。

Tensorflow/slim 以及其他高级库允许张量格式 BHWC (batch_size, height, width, channel. 下同) 默认或BCHW (以获得更好的性能)。

在这两种格式之间转换权重时,权重 [in_channel, out_channel]第一个 fc (全连接层,在 conv 层之后)必须重新整形为 [last_conv_channel, height, width, out_channel]例如,然后转置为 [height, width, last_conv_channel, out_channel]并再次 reshape 为 [in_channel, out_channel] .

如果您使用转换权重而不是完全连接的权重,则这种转换将显式应用于 fc 层(实际上是转换权重)。肯定会避免转换错误。

关于tensorflow - 为什么 slim.nets.vgg 使用 conv2d 而不是全连接层?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42052750/

相关文章:

python - Tensorflow 训练损失在不同的运行中具有宏观相似性

python - TensorFlow:如何在急切执行期间将 DeferredTensor 转换为 Tensor(以执行组标准化)?

python - pyinstaller ModuleNotFoundError

python - import_meta_graph 失败,数据丢失 : not an sstable (bad magic number)

deep-learning - Tensorflow 和变量范围 - 如何正确重用范围?

Tensorflow convert_to_tensor TypeError : List of Tensors when single Tensor expected

python - 如何减少VGG16中间层瓶颈特征的大小?

python - TF2 中的 tf.print 未打印到输出

python - 凯拉斯 + tensorflow : 'ConvLSTM2D' object has no attribute 'outbound_nodes'

python - Tensorflow:计算标签的逆计数