CA-Net icon indicating copy to clipboard operation
CA-Net copied to clipboard

Problem with the use of the dropout layer

Open hwei-cs opened this issue 3 years ago • 6 comments

In your code, drop_out=True https://github.com/HiLab-git/CA-Net/blob/94f2624ee6344a960655183b9c1cc8dfb088498a/Models/networks/network.py#L55 https://github.com/HiLab-git/CA-Net/blob/94f2624ee6344a960655183b9c1cc8dfb088498a/Models/networks/network.py#L36 https://github.com/HiLab-git/CA-Net/blob/94f2624ee6344a960655183b9c1cc8dfb088498a/Models/networks/network.py#L39 https://github.com/HiLab-git/CA-Net/blob/94f2624ee6344a960655183b9c1cc8dfb088498a/Models/layers/channel_attention_layer.py#L95-L96

I think this line of code will affect the results when testing. Because you init the dropout layer in forward function, the model.eval() can not change the status of this layer.

You can test it with the following code

import torch
from torch import nn
import numpy as np

class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.out = nn.Dropout2d(0.5)

    def forward(self, x):
        out = nn.Dropout2d(0.5)(x)
        # out = self.out(x)
        return out

if __name__ == '__main__':
    model = Net()
    model.eval()
    input_npy = np.array([[1.0, 2.0], [3.0, 4.0]])
    input_tensor = torch.from_numpy(input_npy)
    output = model(input_tensor)
    print(output)

If I didn't understand your code correctly, sorry in advance

hwei-cs avatar Aug 26 '21 13:08 hwei-cs

yes, there are mistakes, thanks for your feedback. I will correct it later.

JoeGue avatar Nov 18 '21 09:11 JoeGue

If you use this code in your paper experiment, I'm afraid your experimental results can't be reproduced.

hwei-cs avatar Nov 18 '21 09:11 hwei-cs

The dropout mistake does not affect the experimental results.

HeyWhale8 @.***> 于2021年11月18日周四 下午5:36写道:

If you use this code in your paper experiment, I'm afraid your experimental results can't be reproduced.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/HiLab-git/CA-Net/issues/4#issuecomment-972693235, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFSH2RQV2VA3LHFBXUK55KTUMTCI3ANCNFSM5C3NMTXQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

JoeGue avatar Nov 18 '21 14:11 JoeGue

Can you run your pre-trained model on a test set several times? Are the test results the same? If the results of multiple tests are inconsistent, then why are the results of your experiments convincing

hwei-cs avatar Nov 18 '21 15:11 hwei-cs

In the paper, the result is an average of three times test as I mentioned in the paper.

HeyWhale8 @.***> 于2021年11月18日周四 下午11:39写道:

Can you run your pre-trained model on a test set several times? Are the test results the same? If the results of multiple tests are inconsistent, then why are the results of your experiments convincing

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/HiLab-git/CA-Net/issues/4#issuecomment-972981961, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFSH2RVKPXJU5EO2ZG5ERKDUMUM2LANCNFSM5C3NMTXQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

JoeGue avatar Nov 18 '21 15:11 JoeGue

It seems that the word "three times" is not mentioned in your article (TMI version). Am I missing it?

hwei-cs avatar Nov 19 '21 02:11 hwei-cs