Efficient-AI-Backbones icon indicating copy to clipboard operation
Efficient-AI-Backbones copied to clipboard

What are the reduce_ratios and y in your VIG code?

Open junleiz opened this issue 3 years ago • 6 comments

Thank you very much for your released code for VIG. I spent some time on reading your code carefully. But I am confused about some parts of code, could you please give some hints? @iamhankai

  1. reduce_ratios = [4, 2, 1, 1] I am confused about the reduced_ratios. I read from the paper that the sizes of each stages is 1/2 of their precedure stages. So what the reduce ratios are used for?
  2. in the code:
class MRConv2d(nn.Module):
    """
    Max-Relative Graph Convolution (Paper: https://arxiv.org/abs/1904.03751) for dense data type
    """
    def __init__(self, in_channels, out_channels, act='relu', norm=None, bias=True):
        super(MRConv2d, self).__init__()
        self.nn = BasicConv([in_channels*2, out_channels], act, norm, bias)

    def forward(self, x, edge_index, y=None):
        x_i = batched_index_select(x, edge_index[1])
        if y is not None:
            x_j = batched_index_select(y, edge_index[0])
        else:
            x_j = batched_index_select(x, edge_index[0])
        x_j, _ = torch.max(x_j - x_i, -1, keepdim=True)
        b, c, n, _ = x.shape
        x = torch.cat([x.unsqueeze(2), x_j.unsqueeze(2)], dim=2).reshape(b, 2 * c, n, _)
        return self.nn(x) 

What the y stands for? I am really confused about the y as I found y is calculated from x based on the reduce_ratios. But I can not relate y or reduce_ratios to formulars in your VIG or Deep GCN. Could you please give me some advices? Thank you!

junleiz avatar Jul 04 '22 07:07 junleiz

Thanks for the attention. Here we reduce the number of nodes by reduce_ratio so as to reduce the computational cost of distance calculation.

iamhankai avatar Jul 04 '22 08:07 iamhankai

Thanks for the attention. Here we reduce the number of nodes by reduce_ratio so as to reduce the computational cost of distance calculation. Thank you for your rapid reply. I also found that your dilation is always set to 1 in your code: min(idx // 4 + 1, max_dilation) . Does this because you have reduced the nodes by pooling based on reduce_ration? Thank you very much for your precious time!

junleiz avatar Jul 04 '22 09:07 junleiz

Dilation is not always 1 since idx is the layer index in min(idx // 4 + 1, max_dilation).

iamhankai avatar Jul 04 '22 10:07 iamhankai

hi @iamhankai I am confused with this line x_j, _ = torch.max(x_j - x_i, -1, keepdim=True) in MRConv code,

x_j=[b, c, n, k] is the selected node by computing the distance, after this line x_j=[b, c, n, 1]. It seems that the MRConv only consider one node with the largest distance?

PanXiebit avatar Jul 08 '22 06:07 PanXiebit

@PanXiebit The torch.max is applied at element-wise level, not the vector-wise.

iamhankai avatar Jul 08 '22 09:07 iamhankai

@iamhankai Thanks, I understand!

PanXiebit avatar Jul 08 '22 11:07 PanXiebit