本文主要是介绍RuntimeError: invalid argument 4: out of range at pytorch/torch/lib/TH/generic/THTensor.c:439,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
使用from torchvision.utils import save_image保存图像时,出现错误:
File “/usr/local/lib/python2.7/dist-packages/torchvision/utils.py”, line 51, in save_image
grid = make_grid(tensor, nrow=nrow, padding=padding)
File “/usr/local/lib/python2.7/dist-packages/torchvision/utils.py”, line 38, in make_grid
.narrow(2, x*width+1+padding//2, width-padding)\
RuntimeError: invalid argument 4: out of range at /pytorch/torch/lib/TH/generic/THTensor.c:439
原因是torchvision版本不对,解决方法是卸载torchvision,并重新安装,
pip uninstall torchvision pip install torchvision
这篇关于RuntimeError: invalid argument 4: out of range at pytorch/torch/lib/TH/generic/THTensor.c:439的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!