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

CodeCamp #33 [Fix]:add type hints for res_layer, se_layer,normed_predictor,positional_encoding #9346

Merged
merged 7 commits into from
Jan 3, 2023

Conversation

ZhikangNiu
Copy link
Contributor

Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily get feedback. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.

Motivation

超级视客营mmdet基础任务,选择链接中任一 part 代码添加 type hints,为part6的res_layer添加type hints

Modification

为其中的Reslayer和SimplifiedBasicBlock添加了type hint
Please briefly describe what modification is made in this PR.

BC-breaking (Optional)

Does the modification introduce changes that break the backward-compatibility of the downstream repos?
If so, please describe how it breaks the compatibility and how the downstream projects should modify their code to keep compatibility with this PR.

Use cases (Optional)

If this PR introduces a new feature, it is better to list some use cases here, and update the documentation.

Checklist

  1. Pre-commit or other linting tools are used to fix the potential lint issues.
  2. The modification is covered by complete unit tests. If not, please add more unit test to ensure the correctness.
  3. If the modification has potential influence on downstream projects, this PR should be tested with downstream projects, like MMDet or MMCls.
  4. The documentation has been modified accordingly, like docstring or example tutorials.

@CLAassistant
Copy link

CLAassistant commented Nov 18, 2022

CLA assistant check
All committers have signed the CLA.

mmdet/models/layers/res_layer.py Outdated Show resolved Hide resolved
mmdet/models/layers/res_layer.py Show resolved Hide resolved
@BIGWangYuDong
Copy link
Collaborator

@NoFish-528 Thanks for your PR! You can follow the comments to update your code.

@ZhikangNiu
Copy link
Contributor Author

@NoFish-528 Thanks for your PR! You can follow the comments to update your code.

I have updated my code. : ) @BIGWangYuDong

@ZwwWayne ZwwWayne added this to the 3.0.0rc5 milestone Nov 21, 2022
@ZwwWayne ZwwWayne requested a review from zytx121 December 5, 2022 08:07
Copy link
Collaborator

@BIGWangYuDong BIGWangYuDong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 109 should update

@@ -114,19 +119,19 @@ class SimplifiedBasicBlock(BaseModule):
expansion = 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 109: super().init(*layers)

@ZhikangNiu ZhikangNiu changed the title [Fix]:add type hints for res_layer [WIP]:add type hints for res_layer, se_layer,normed_predictor,positional_encoding Dec 12, 2022
@ZhikangNiu
Copy link
Contributor Author

add type hints for res_layer, se_layer,normed_predictor,positional_encoding

@ZhikangNiu ZhikangNiu changed the title [WIP]:add type hints for res_layer, se_layer,normed_predictor,positional_encoding [Fix]:add type hints for res_layer, se_layer,normed_predictor,positional_encoding Dec 14, 2022
Copy link
Collaborator

@BIGWangYuDong BIGWangYuDong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. All Default: change to Defaults to
  2. some typehint are not added
  3. add xx=xx in some necessary place, such as super().xxx(xxx=xxx)

@@ -50,23 +56,23 @@ class NormedConv2d(nn.Conv2d):
eps (float, optional): The minimal value of divisor to
keep numerical stability. Default to 1e-6.
norm_over_kernel (bool, optional): Normalize over kernel.
Default to False.
Default: False.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default: -> Defaults to

eps: float = 1e-6,
offset: float = 0.,
init_cfg: OptMultiConfig = None) -> None:
super().__init__(init_cfg)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

init_cfg=init_cfg

@@ -54,7 +56,7 @@ def __init__(self,
self.eps = eps
self.offset = offset

def forward(self, mask):
def forward(self, mask) -> Tensor:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the type of mask

col_num_embed: int = 50,
init_cfg: MultiConfig = dict(type='Uniform', layer='Embedding')
) -> None:
super().__init__(init_cfg)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

init_cfg=init_cfg

@@ -140,7 +140,7 @@ class ChannelAttention(BaseModule):
Args:
channels (int): The input (and output) channels of the attention layer.
init_cfg (dict or list[dict], optional): Initialization config dict.
Defaults to None.
Defaults: None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defaults to None

@RangiLyu RangiLyu changed the title [Fix]:add type hints for res_layer, se_layer,normed_predictor,positional_encoding CodeCamp #33 [Fix]:add type hints for res_layer, se_layer,normed_predictor,positional_encoding Dec 20, 2022
@ZhikangNiu
Copy link
Contributor Author

  1. All Default: change to Defaults to
  2. some typehint are not added
  3. add xx=xx in some necessary place, such as super().xxx(xxx=xxx)

@BIGWangYuDong Thank you for your suggestion. I update the code with your suggestion

@ZhikangNiu ZhikangNiu requested review from BIGWangYuDong and removed request for zytx121 December 28, 2022 12:22
Copy link
Collaborator

@BIGWangYuDong BIGWangYuDong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some questions in this PR,

  1. Default to -> Defaults to . It should be Defaults to in docstrings. (Need to check in this PR)
  2. It is suggested to add docstrings in these python files, I give you some example, which may help you,

mmdet/models/layers/positional_encoding.py Outdated Show resolved Hide resolved
mmdet/models/layers/normed_predictor.py Show resolved Hide resolved
mmdet/models/layers/normed_predictor.py Show resolved Hide resolved
mmdet/models/layers/normed_predictor.py Show resolved Hide resolved
mmdet/models/layers/normed_predictor.py Show resolved Hide resolved
mmdet/models/layers/positional_encoding.py Outdated Show resolved Hide resolved
mmdet/models/layers/res_layer.py Outdated Show resolved Hide resolved
mmdet/models/layers/res_layer.py Outdated Show resolved Hide resolved
mmdet/models/layers/se_layer.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@BIGWangYuDong BIGWangYuDong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ZwwWayne ZwwWayne merged commit f26153b into open-mmlab:dev-3.x Jan 3, 2023
yumion pushed a commit to yumion/mmdetection that referenced this pull request Jan 31, 2024
…nal_encoding (open-mmlab#9346)

* [Fix]:add type hints for res_layer

* Update mmdet/models/layers/res_layer.py

Co-authored-by: BigDong <[email protected]>

* [Fix]:add type hint of norm1 and norm2

* [WIP]:add res_layer type hints

* [WIP]:add layer type hints about issue 9234

* [FIX]:add all type hints and change some function note

* [FIX]:add docstrings and change default -> defaults

Co-authored-by: BigDong <[email protected]>
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

Successfully merging this pull request may close these issues.

None yet

4 participants