最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

pytorch - Equivalent of _new_empty_tensor from torchvision in pure torch function - Stack Overflow

programmeradmin5浏览0评论

I am trying to use a vision transformer repository () which uses a version of torch and torchvision. Anyway, because exact versions are not given and torch is super fast at deprecating versions I guess I am in the unpleasant situation to try to find what combination of those two packages would work for me.

The error message is this one:

cannot import name '_new_empty_tensor' from 'torchvision.ops'

The simpler question would be which is the last version of torchvision that includes _new_empty_tensor?

But I would be happy with a workaround. For example inspecting the code I found the usage for the later to be:

_new_empty_tensor(input, output_shape)

which to me it just creates an empty tensor with the given dimensions. Correct me if I am wrong here. So, could I just use torch instead and create a torch Tensor instead? Would there be any issue? And as a side question why torchvision even introduced such functions? Isn't it supposed to just provide some additional functionality for images? Am I missing something here?

I am trying to use a vision transformer repository (https://github/wangjian123799/L-DETR) which uses a version of torch and torchvision. Anyway, because exact versions are not given and torch is super fast at deprecating versions I guess I am in the unpleasant situation to try to find what combination of those two packages would work for me.

The error message is this one:

cannot import name '_new_empty_tensor' from 'torchvision.ops'

The simpler question would be which is the last version of torchvision that includes _new_empty_tensor?

But I would be happy with a workaround. For example inspecting the code I found the usage for the later to be:

_new_empty_tensor(input, output_shape)

which to me it just creates an empty tensor with the given dimensions. Correct me if I am wrong here. So, could I just use torch instead and create a torch Tensor instead? Would there be any issue? And as a side question why torchvision even introduced such functions? Isn't it supposed to just provide some additional functionality for images? Am I missing something here?

Share Improve this question asked 3 hours ago EyprosEypros 5,7237 gold badges52 silver badges85 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

The last version of torchvision that includes ops._new_empty_tensor is 0.8.2, which is compatible with PyTorch 1.7.1. That said, the requirements.txt in the repo you linked includes:

torch>=1.5.0
torchvision>=0.6.0

From this, I would guess that PyTorch 1.5.0 and torchvision 0.6.0 are what the devs actually used when they trained that model.

发布评论

评论列表(0)

  1. 暂无评论