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

On the inconsistency between the printed network structure and the paper #59

Open
PowerKaly opened this issue Dec 8, 2023 · 0 comments

Comments

@PowerKaly
Copy link

PowerKaly commented Dec 8, 2023

Hello, author
I added at the end of models/fasternet.py

if __name__ == "__main__":
    model = FasterNet(
        mlp_ratio=2.0,
        embed_dim=128,
        depths=(1, 2, 13, 2),
        drop_path_rate=0.15,
        act_layer='RELU',
        fork_feat=True,
    )

    print(model)

Try to print the network structure, and the result is

If for detection, please install mmdetection first
FasterNet(
  (patch_embed): PatchEmbed(
    (proj): Conv2d(3, 128, kernel_size=(4, 4), stride=(4, 4), bias=False)
    (norm): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
  )
  (stages): Sequential(
    (0): BasicStage(
      (blocks): Sequential(
        (0): MLPBlock(
          (drop_path): Identity()
          (mlp): Sequential(
            (0): Conv2d(128, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)
            (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
            (2): ReLU(inplace=True)
            (3): Conv2d(256, 128, kernel_size=(1, 1), stride=(1, 1), bias=False)
          )
          (spatial_mixing): Partial_conv3(
            (partial_conv3): Conv2d(32, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          )
        )
      )
    )
    (1): PatchMerging(
      (reduction): Conv2d(128, 256, kernel_size=(2, 2), stride=(2, 2), bias=False)
      (norm): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
    )
    (2): BasicStage(
      (blocks): Sequential(
        (0): MLPBlock(
          (drop_path): DropPath(drop_prob=0.009)
          (mlp): Sequential(
            (0): Conv2d(256, 512, kernel_size=(1, 1), stride=(1, 1), bias=False)
            (1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
            (2): ReLU(inplace=True)
            (3): Conv2d(512, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)
          )
          (spatial_mixing): Partial_conv3(
            (partial_conv3): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          )
        )
        (1): MLPBlock(
          (drop_path): DropPath(drop_prob=0.018)
          (mlp): Sequential(
            (0): Conv2d(256, 512, kernel_size=(1, 1), stride=(1, 1), bias=False)
            (1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
            (2): ReLU(inplace=True)
            (3): Conv2d(512, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)
          )
          (spatial_mixing): Partial_conv3(
            (partial_conv3): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          )
        )
      )
    )
    (3): PatchMerging(
      (reduction): Conv2d(256, 512, kernel_size=(2, 2), stride=(2, 2), bias=False)
      (norm): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
    )
........

As you can see from here.

(mlp): Sequential(
           (0): Conv2d(256, 512, kernel_size=(1, 1), stride=(1, 1), bias=False)
           (1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
           (2): ReLU(inplace=True)
           (3): Conv2d(512, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)
         )
         (spatial_mixing): Partial_conv3(
           (partial_conv3): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
         )

It goes through two 1x1 convolutions and then 3x3. Contrary to the paper, I don't know if there is something wrong with my understanding. I hope you can give me some advice.thinks 👍 :)

@PowerKaly PowerKaly changed the title 关于网络结构打印出来和论文不一致的问题 On the inconsistency between the printed network structure and the paper Dec 8, 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