在PyTorch中求张量的自举计数器

2024-09-28 23:00:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用PyTorch训练一个网络。我正在浏览autograd文档,其中提到,对于每个张量,autograd都会实现一个计数器来跟踪任何张量的“版本”。如何得到图中任何张量的计数器

我需要它的原因。

我遇到了自动签名错误

[torch.cuda.FloatTensor [x, y, z]], which is output 0 of torch::autograd::CopySlices, is at version 7; expected version 6 instead. Hint: the backtrace further above shows the operation that failed to compute its gradient. The variable in question was changed in there or anywhere later. Good luck!

这对我来说并不新鲜,我以前也成功地处理过。这一次我不明白为什么张量会在第7版而不是第6版。为了回答这个问题,我想知道运行中任何给定点的版本

谢谢


Tags: thein文档版本网络isversion错误