Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appearing 'nan' value during the training time by using my own counting dataset? #12

Open
zhilyzhang opened this issue Mar 30, 2023 · 0 comments

Comments

@zhilyzhang
Copy link

zhilyzhang commented Mar 30, 2023

Thank you for your interesting work and it is very useful in practical applications. I encountered this question, when training my own counting dataset? I added "print" in matcher.py and I finded there were NAN values. why? please help me, thank you very much!

def forward(self, features, patches):
    bs, c, h, w = features.shape
    features = features.flatten(2).permute(2, 0, 1)  # hw * bs * dim
    
    proj_feat = self.query_conv(features)
    patches_feat = self.key_conv(patches)
    patches_ca = self.activation(self.dynamic_pattern_conv(patches_feat))
    
    proj_feat = proj_feat.permute(1, 0, 2)
    patches_feat = (patches_feat * (patches_ca + 1)).permute(1, 2, 0)  # bs * c * exemplar_number        
    energy = torch.bmm(proj_feat, patches_feat)                        # bs * hw * exemplar_number
    print("energy.mean(), features.mean(): ", energy.mean(), features.mean())

energy.mean(), features.mean(): tensor(-14.2665, device='cuda:4', grad_fn=) tensor(0.1236, device='cuda:4', grad_fn=)
torch.Size([8, 1024]) torch.Size([8, 1024]) 0.0
energy.mean(), features.mean(): tensor(-17.7250, device='cuda:4', grad_fn=) tensor(0.1354, device='cuda:4', grad_fn=)
torch.Size([8, 1024]) torch.Size([8, 1024]) 0.0
energy.mean(), features.mean(): tensor(nan, device='cuda:4', grad_fn=) tensor(nan, device='cuda:4', grad_fn=)

@zhilyzhang zhilyzhang changed the title Appearing Appearing 'nan' value during the training time by using my own counting dataset? Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant