【问题标题】:How to reshape the pre-trained weights to input them to 3d convoluional neural network?如何重塑预训练的权重以将它们输入到 3d 卷积神经网络?
【发布时间】:2016-11-08 14:40:59
【问题描述】:

我使用 Matlab 为 3d 卷积层预训练了权重。权重是一个尺寸为 (512,4,4,4,160) 的 5d 张量。 [out_channels, filter_depth, filter_height, filter_width, in_channels]

现在我想将其输入为初始权重,以便在 tensorflow 的 tf.nn.conv3d 中进行微调。我看到 3d 卷积神经网络允许的权重形状应该是:(4,4,4,160,512).[filter_depth, filter_height, filter_width, in_channels, out_channels]。我可以只使用 tf.Variable().reshape(4,4,4,160,512) 吗?但我觉得如果我只使用重塑,它不是正确的权重。

【问题讨论】:

    标签: filter 3d tensorflow reshape


    【解决方案1】:

    tf.transpose 操作可以重新排序轴:https://www.tensorflow.org/versions/r0.11/api_docs/python/array_ops.html#transpose

    假设张量input 的初始形状为(512,4,4,4,160),则tf.transpose(input, perm=[4,1,2,3,0]) 的输出张量将具有(160,4,4,4,512) 的形状。

    此外,您可能需要沿某些轴或多个轴反转您的权重。在张量流中,卷积被实现为互相关:https://www.tensorflow.org/versions/r0.11/api_docs/python/nn.html#convolution

    【讨论】:

      猜你喜欢
      • 2020-12-07
      • 2018-05-01
      • 2016-07-24
      • 2019-01-14
      • 1970-01-01
      • 1970-01-01
      • 2017-07-30
      • 2016-07-21
      • 2014-09-05
      相关资源
      最近更新 更多