Comments (6)
Would it be enough to check tensor.is_leaf before accessing grad in the toEpilog() logic?
from torchsharp.
I'm confused -- all the instances of .grad
in Module are accessing parameters. How can they be non-leaf tensors?
from torchsharp.
So, should #1322 also be closed, then?
from torchsharp.
That's a bit tricky.
We can't just check param.requires_grad
because it might be a non-leaf tensor but retains_grad
. I'm also not sure whether there are any other situations.
from torchsharp.
Yes there are... We can simply do that in PyTorch:
import torch.nn
x = torch.zeros([], requires_grad=False)
x.grad = torch.zeros([]) + 10
print(x.grad) # tensor(10.)
So we can never know whether their is a grad
before we true access it...
Perhaps the only solution is to add a new C++ method for this. Or find a way to temporarily suppress warnings.
from torchsharp.
Hmmm... This issue was created due to #1322 . In that issue, this.conv.weight[..] = nn.Parameter(x.view(1, c1, 1, 1));
was used, which made it a non-leaf tensor.
Well I have just reconsidered about this... I suppose it's a misuse of slicing, and a warning is just what we want in this situation.
from torchsharp.
Related Issues (20)
- in `RemoveDisposeScope`, we can't assume that `DisposeScopeStack.Peek() == disposeScope` HOT 4
- equivalent of PyTorch `data` HOT 1
- warnings cannot be accessed in notebooks HOT 1
- TryLoadNativeLibraryFromFile shouldn't just swallow all exceptions
- Calls to NativeLibrary should not assume explicit paths
- In PyTorch, the `non_blocking` parameter of the `torch.to` method is not present in TorchSharp.
- How do I get the value of such an attribute, just for display purposes. HOT 4
- How to set default device type in torchsharp.
- expose lr scheduler fields HOT 4
- Add register_pre_hook and register_hook for generic module class? HOT 3
- How do I turn off these warnings? HOT 17
- Linear module creates parameter on cpu even after I set default device to meta HOT 1
- Request tensor factory methods accepting Span<T> HOT 9
- The function torch.cuda.empty_cache() is missing. HOT 6
- Move to libtorch 2.4.0 HOT 1
- Unexpected parameters HOT 11
- MultivariateNormal.log_prob() exception in TorchSharp but works in pytorch HOT 16
- Builds fail after package validation PR merged HOT 2
- Modernize torchsharp infrastructure
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from torchsharp.