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

conv = nn.Conv2d(c1, 1, 1, bias=False).requires_grad_(False) #913

Closed
williamlzw opened this issue Feb 15, 2023 · 1 comment · Fixed by #915
Closed

conv = nn.Conv2d(c1, 1, 1, bias=False).requires_grad_(False) #913

williamlzw opened this issue Feb 15, 2023 · 1 comment · Fixed by #915

Comments

@williamlzw
Copy link

williamlzw commented Feb 15, 2023

conv = nn.Conv2d(c1, 1, 1, bias=False).requires_grad_(False)
self.conv.weight.data[:] = nn.Parameter(x.view(1, c1, 1, 1))

https://github.com/ultralytics/ultralytics/blob/main/ultralytics/nn/modules.py
line73
requires_grad_(False) ? not support in torchsharp.
conv.weight.data[:] = nn.Parameter(x.view(1, c1, 1, 1))

@NiklasGustafsson
Copy link
Contributor

Thanks for reporting the issue. It's been implemented incorrectly (easy fix):

            public Tensor requires_grad_(bool requires_grad = true)
            {
                this.requires_grad = true;
                return this;
            }

In the meantime, use with_requires_grad() or set the requires_grad property directly.

@NiklasGustafsson NiklasGustafsson linked a pull request Feb 15, 2023 that will close this issue
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 a pull request may close this issue.

2 participants