我正在阅读暹罗网络的源代码。但是我不明白互相关代码中正在发生什么。代码是:
def xcorr(self, z, x):
"""
correlation layer as in the original SiamFC (convolution process in fact)
"""
batch_size_x, channel_x, w_x, h_x = x.shape
x = torch.reshape(x, (1, batch_size_x * channel_x, w_x, h_x))
# group convolution
out = F.conv2d(x, z, groups = batch_size_x)
batch_size_out, channel_out, w_out, h_out = out.shape
xcorr_out = torch.reshape(out, (channel_out, batch_size_out, w_out, h_out))
return xcorr_out
我可以看到可以使用conv操作执行xcorr。但是,这里进行两次重塑的想法是什么? (xcorr函数的两个输入在#batch-size和#channel上具有相同的大小)