Closed dontLoveBugs closed 5 years ago
so v1 or v2 ,which one is right ?or both of v1 and v2 are wrong?
Here is my code according to the paper:
def eight_way_propagation_v3(self, weight_matrix, blur_matrix, kernel):
[batch_size, channels, height, width] = weight_matrix.size()
weight_abs = torch.abs(weight_matrix)
self.avg_conv = nn.Conv2d(in_channels=1, out_channels=1, kernel_size=kernel, stride=1,
padding=(kernel - 1) // 2, bias=False)
weight = torch.ones(1, 1, kernel, kernel).cuda()
weight[0, 0, (kernel - 1) // 2, (kernel - 1) // 2] = 0 # 中心点置为0? #kenel= [1,1,1]
self.avg_conv.weight = nn.Parameter(weight) # [1,0,1]
for param in self.avg_conv.parameters(): # [1,1,1]
param.requires_grad = False
weight_sum = self.avg_conv(weight_matrix)
abs_sum=self.avg_conv(weight_abs)
out=torch.div((abs_sum-weight_sum)*blur_matrix+self.avg_conv(weight_matrix*blur_matrix),abs_sum)
return out
Where weight_matrix can be negative
Here is my code according to the paper:
def eight_way_propagation_v3(self, weight_matrix, blur_matrix, kernel): [batch_size, channels, height, width] = weight_matrix.size() weight_abs = torch.abs(weight_matrix) self.avg_conv = nn.Conv2d(in_channels=1, out_channels=1, kernel_size=kernel, stride=1, padding=(kernel - 1) // 2, bias=False) weight = torch.ones(1, 1, kernel, kernel).cuda() weight[0, 0, (kernel - 1) // 2, (kernel - 1) // 2] = 0 # 中心点置为0? #kenel= [1,1,1] self.avg_conv.weight = nn.Parameter(weight) # [1,0,1] for param in self.avg_conv.parameters(): # [1,1,1] param.requires_grad = False weight_sum = self.avg_conv(weight_matrix) abs_sum=self.avg_conv(weight_abs) out=torch.div((abs_sum-weight_sum)*blur_matrix+self.avg_conv(weight_matrix*blur_matrix),abs_sum) return out
Where weight_matrix can be negative
Did you find any performance difference between these two version?
True, the released version is one version around ECCV 2018 submission time. We did 9 value normalization, rather than 8 values.
In your paper, The convolutional transformation functional with a kernel size of k for each time step t could be written as:![image](https://user-images.githubusercontent.com/17598076/49693518-3661e000-fbb0-11e8-98c4-f8dacc17c3de.png)
But I find the implementation of Eq. (1) is different in your code. According to your code, k_i, j(a, b) = k^_i, j(a, b) / ∑_a, b|k^_i, j(a, b)|, the constraint of a,b ≠ 0 should be removed. I verified my assumption by modifying your code. In your code, eight_eight_way_propagation is:
I modified your code as:
The test code is:
I get the same output!![image](https://user-images.githubusercontent.com/17598076/49693598-34991c00-fbb2-11e8-82c5-7e9909a94cec.png)