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

Issues with the published code (and fixes) #9

Open
neosr-project opened this issue Oct 22, 2024 · 2 comments
Open

Issues with the published code (and fixes) #9

neosr-project opened this issue Oct 22, 2024 · 2 comments

Comments

@neosr-project
Copy link

neosr-project commented Oct 22, 2024

Hi, thanks for your research.
I took the liberty to fix some issues I've found in the code. I published it here.
In particular, on Block the mlp_ratio is being passed as float. Usually the MLP uses hidden_dim = int(dim * mlp_ratio) but in the official CFSR released code it uses those variables directly, causing the dtype issue. Another issue I've found was using FloatTensor for sobel and laplacian tensors. Instead, the correct solution would be to use .clone() instead (no need, just pass it directly). I've also added a bool for mean normalization, as the default uses values from ImageNet, which tends to cause issues on other datasets.
Again, thank you for releasing the code for this research, the paper is very interesting 👍

@NowLoadY
Copy link

how about this part?

class Layer(nn.Module):
    def __init__(self, dim, depth, dw_size, mlp_ratio=4.0):
        super().__init__()
        self.blocks = nn.ModuleList([
            Block(dim, dw_size, mlp_ratio) for i in range(depth)
        ])
        self.conv = nn.Conv2d(dim, dim, 1)

    def forward(self, x):
        for blk in self.blocks:
            x = blk(x)
        return self.conv(x) + x

modify:

class Layer(nn.Module):
    def __init__(self, dim, depth, dw_size, mlp_ratio=4.):
        super().__init__()
        self.blocks = nn.ModuleList([
            Block(dim, dw_size, mlp_ratio) for i in range(depth)
        ])
        self.conv = nn.Conv2d(dim, dim, 1)

    def forward(self, x):
        identity = x
        for blk in self.blocks:
            x = blk(x) 
        return self.conv(identity) + x

I wanted to add that I'm not a professional in this field, so I'm not entirely certain about the changes I've suggested. However, based on my understanding, it seems to me that the modification might be beneficial.

@neosr-project
Copy link
Author

@NowLoadY yes, already fixed on the code posted above, if you have interest

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

2 participants