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

在调用 forward() 方法时,is_eval 参数被传递了多次 #8

Open
cuifeixiang opened this issue Sep 9, 2024 · 11 comments
Open

Comments

@cuifeixiang
Copy link

您好,我在复现SIGA_T时,出现了参数多次传递的问题,请问是什么原因呢?
Traceback (most recent call last):
File "/root/autodl-tmp/SIGA/SIGA_T/test.py", line 413, in
test(opt)
File "/root/autodl-tmp/SIGA/SIGA_T/test.py", line 352, in test
_, accuracy_by_best_model, _, _, _, _, _, _ = validation(
File "/root/autodl-tmp/SIGA/SIGA_T/test.py", line 157, in validation
model(image, None, target, None, None, is_eval=True) # final
File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py", line 159, in forward
return self.module(*inputs[0], **kwargs[0])
File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/root/autodl-tmp/SIGA/SIGA_T/models.py", line 40, in forward
prediction = self.mgp_str(input, mask, text, len_target, iteration, is_eval=is_eval)#
File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
TypeError: forward() got multiple values for argument 'is_eval'

@TongkunGuan
Copy link
Owner

TongkunGuan commented Sep 9, 2024

您好,我在复现SIGA_T时,出现了参数多次传递的问题,请问是什么原因呢? Traceback (most recent call last): File "/root/autodl-tmp/SIGA/SIGA_T/test.py", line 413, in test(opt) File "/root/autodl-tmp/SIGA/SIGA_T/test.py", line 352, in test _, accuracy_by_best_model, _, _, _, _, _, _ = validation( File "/root/autodl-tmp/SIGA/SIGA_T/test.py", line 157, in validation model(image, None, target, None, None, is_eval=True) # final File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(*input, **kwargs) File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py", line 159, in forward return self.module(*inputs[0], **kwargs[0]) File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(*input, **kwargs) File "/root/autodl-tmp/SIGA/SIGA_T/models.py", line 40, in forward prediction = self.mgp_str(input, mask, text, len_target, iteration, is_eval=is_eval)# File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(*input, **kwargs) TypeError: forward() got multiple values for argument 'is_eval'

Please refer to line 352 in test.py

model, criterion, evaluation_loader, converter, opt)

We don't add is_eval=True

@cuifeixiang
Copy link
Author

  Hello, I don't add is_eval=True, here is my code:    

_, accuracy_by_best_model, _, _, _, _, _, _ = validation(
model, criterion, evaluation_loader, converter, opt)

@cuifeixiang
Copy link
Author

I haven't modified your code.

@TongkunGuan
Copy link
Owner

I haven't modified your code.

You are right!

@TongkunGuan
Copy link
Owner

TongkunGuan commented Sep 10, 2024

  Hello, I don't add is_eval=True, here is my code:    

_, accuracy_by_best_model, _, _, _, _, _, _ = validation( model, criterion, evaluation_loader, converter, opt)

我现在已经没有这个虚拟环境了 从目前的代码上我暂时也看不出来问题出在哪 但可以看的出来这应该是一个基础的代码问题 你可以手动调试一下解决它

@cuifeixiang
Copy link
Author

我尝试了很多方法都没有解决,所以才向您发出提问,非常感谢您在百忙之中进行回复。

@TongkunGuan
Copy link
Owner

我尝试了很多方法都没有解决,所以才向您发出提问,非常感谢您在百忙之中进行回复。

我觉得你可以在test.py的157行 开始逐步运行 直到程序跳到models.py的40行 看看is_eval的参数到底是怎么传的

@cuifeixiang
Copy link
Author

cuifeixiang commented Sep 11, 2024 via email

@TongkunGuan
Copy link
Owner

我已经试过在此处Debug并输出is_eval,但是is_eval在此过程中只输出了一次,并没有发现多次传递,直到再次回到test(opt)开始报错。

------------------ 原始邮件 ------------------ 发件人: "Tongkun @.>; 发送时间: 2024年9月11日(星期三) 中午12:01 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [TongkunGuan/SIGA] 在调用 forward() 方法时,is_eval 参数被传递了多次 (Issue #8) 我尝试了很多方法都没有解决,所以才向您发出提问,非常感谢您在百忙之中进行回复。 我觉得你可以在test.py的157行 开始逐步运行 直到程序跳到models.py的40行 看看is_eval的参数到底是怎么传的 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

换个思路 把is_eval全部取消掉 然后把相关的代码部分写死 看看呢?

@cuifeixiang
Copy link
Author

cuifeixiang commented Sep 12, 2024 via email

@cuifeixiang
Copy link
Author

您好,文章中提到的自监督文本分割代码是不是并没有提供啊?

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