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

BUG in the implementation of HeatmapGenerator #13

Open
dalmia opened this issue Sep 26, 2018 · 3 comments
Open

BUG in the implementation of HeatmapGenerator #13

dalmia opened this issue Sep 26, 2018 · 3 comments

Comments

@dalmia
Copy link

dalmia commented Sep 26, 2018

Hi @zoogzog
Thanks for writing everything. This has been really helpful. However, when I was reading the code for the visualization, I realized that there is a bug in the code:

self.model = model.module.densenet121.features
self.model.eval()
        
#---- Initialize the weights
self.weights = list(self.model.parameters())[-2]

Once you have assigned densenet121.features to self.model, it loses the weights of the final classification layer and we need those weights for calculating CAM. Instead you are using weights from some part of densenet121.features, which gives rise to the error in visualization. I've already made the change and added a few other things that improved my visualization, taken from https://github.com/jrzech/reproduce-chexnet here: https://github.com/dalmia/chexnet/blob/master/HeatmapGenerator.py

I tried creating a Pull Request but apparently it cannot detect any difference between our repos.

@zoogzog
Copy link
Owner

zoogzog commented Sep 27, 2018

Thanks, I will look into the code and will fix it.

@taijizhao
Copy link

Yes, actually I think change line 46 to
self.weights = list(model.module.densenet121.classifier.parameters())[-2]
may fix the problem?

@Makhaon
Copy link

Makhaon commented Feb 2, 2019

I have tried to change the 46 line and got an error in the heatmap generation cycle:

untimeError: The size of tensor a (1024) must match the size of tensor b (8) at non-singleton dimension

Could someone fix an issiue?

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

4 participants