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

[Feature] add model script of cait #547

Merged
merged 1 commit into from
Mar 24, 2023
Merged

Conversation

wcrzlh
Copy link
Collaborator

@wcrzlh wcrzlh commented Mar 20, 2023

Thank you for your contribution to the MindCV repo.
Before submitting this PR, please make sure:

Motivation

The model script of cait is added.

Test Plan

Please use 'create_model' part for testing models in cait.

Related Issues and PRs

Related issue: #424

'first_conv': '', 'classifier': '',
**kwargs
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

缺少default_cfg

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added

}


class Class_Attention(nn.Cell):
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个类名在原作者的实现中就是大写加下划线吗?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

是的

return x_cls


class LayerScale_Block_CA(nn.Cell):
Copy link
Collaborator

Choose a reason for hiding this comment

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

同上


attn = self.q_matmul_k(q, k)

"talking head trick"
Copy link
Collaborator

Choose a reason for hiding this comment

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

这是什么意思?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is a trick used in cait. I have deleted this comment line.

self.gamma_2 = Parameter(init_values * ops.ones((dim), ms.float32), requires_grad=True)

def construct(self, x: Tensor) -> Tensor:

Copy link
Collaborator

Choose a reason for hiding this comment

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

去除不必要空行

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

deleted


self._init_weights()

def _init_weights(self) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

命名与其他文件统一

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed



@register_model
def cait_XXS24_224(pretrained: bool = False, num_classes: int = 1000, in_channels=3, **kwargs) -> CaiT:
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个函数名也是

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

原作者实现中写的就是这样的函数名

@geniuspatrick geniuspatrick merged commit 43c29f6 into mindspore-lab:main Mar 24, 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

Successfully merging this pull request may close these issues.

2 participants