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

Why does the modified code section of the DetectionModel (BaseModel) function need to change the tensor to (2, ch, s, s)? #72

Open
18270737873a opened this issue Feb 25, 2025 · 6 comments

Comments

@18270737873a
Copy link

Why does the modified code section of the DetectionModel (BaseModel) function need to change the tensor to (2, ch, s, s)?I tried to modify it to (1,ch,s,s) and there was no problem。

    try: #there add exception
        m.stride = torch.tensor([s / x.shape[-2] for x in forward(torch.zeros(1, ch, s, s))])  # forward
    except Exception as e:
        if 'Not implemented on the CPU' in str(
                e) or 'Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor)' in str(
            e) or 'CUDA tensor' in str(e) or 'is_cuda()' in str(e) or "Cannot find backend for cpu" in str(e):
            self.model.to(torch.device('cuda'))
            m.stride = torch.tensor([s / x.shape[-2] for x in
                                     forward(torch.zeros(2, ch, s, s).to(torch.device('cuda')))])  # forward
        else:
            raise e
@zhang123-lf
Copy link

你好,请问你用自己的训练成功了吗

@18270737873a
Copy link
Author

你好,请问你用自己的训练成功了吗

成功了,就是不理解 forward(torch.zeros(2, ch, s, s).to(torch.device('cuda')))]) # forward这为什么要改成torch.zeros(2, ch, s, s)

@zhang123-lf
Copy link

你好,请问你用自己的训练成功了吗

成功了,就是不明白forward(torch.zeros(2, ch, s, s).to(torch.device('cuda')))]) #forward这为什么要改成torch.zeros(2, ch, s, s)

请问你出现过训练时,均值平均精度挺高的,但是在验证集上各项数据为0的情况吗

@18270737873a
Copy link
Author

18270737873a commented Feb 28, 2025 via email

@zhang123-lf
Copy link

你好,请问你用自己的训练成功了吗

成功了,就是不明白forward(torch.zeros(2, ch, s, s).to(torch.device('cuda')))]) #forward这为什么要改成torch.zeros(2, ch, s, s)

Image

@zhang123-lf
Copy link

你好,请问你用自己的训练成功了吗

成功了,就是不明白forward(torch.zeros(2, ch, s, s).to(torch.device('cuda')))]) #forward这为什么要改成torch.zeros(2, ch, s, s)
请问,你是做了什么更改吗,可以分享一下你的操作吗

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