when pass the several input into a model, you need to add something.
when run into the error that ' you need a required input or parameter' : you could use * in front of C, but I don't know why, I just try it out for thousands of times to make it work.
when run into the error that ' expect two, but three were given': please check the coherence of the input, make sure the input is the same and they have been passed coherently.
be careful about the iterative structure, they could be more complex, and make sure the input and return are the same dimension.
If still error, you could save the constant input to a file, and load it at the right time. Control the variable into a constant. It's a compromise solution.
def forward(self, A, *C):

本文介绍了在PyTorch中遇到错误时如何处理多输入模型的forward函数。提到了使用'*'来解决'需要一个必需的输入或参数'的问题,以及检查输入一致性以解决'给出两个但提供了三个'的错误。还强调了注意迭代结构中输入和返回维度的一致性,并提供了一种将常量输入保存到文件以控制变量为常量的妥协解决方案。
最低0.47元/天 解锁文章
1062

被折叠的 条评论
为什么被折叠?



