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

PaddleClas 如何实现模型在train 以及 infer 的时候使用不同分支的forword #3122

Open
violetweir opened this issue Apr 13, 2024 · 1 comment

Comments

@violetweir
Copy link

您好麻烦询问一下
RepVgg在训练的时候会使用3x3 1x1 de1Repvgg 模块 在模型导出以及预测的时候可以将3x3 和1x1 的block合成一个block
我也想实现在训练和预测的时候在forward阶段进行不同的操作 paddleclas以及paddle应该如何做才可以呀

@changdazhou
Copy link
Contributor

将forward写成两部分,根据模型的训练状态还是预测状态调用各自部分就好,例如:

def forward(self,state,input):
    if state is 'infer':
        forward_infer(input)
    else:
        forward_train_eval(input)

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