Closed KhaledSharif closed 2 years ago
same Error output with same srcipts
my soft environment :
torch 1.4.0
torchfile 0.1.0
torchvision 0.5.0
hardware:
macbookPro
Traceback (most recent call last):
File "test.py", line 33, in
具有相同规则的相同错误输出
我的软环境: 火炬1.4.0 torchfile 0.1.0 torchvision 0.5.0 硬件: macbookPro
追溯(最近一次通话最近): 文件“ test.py”,第33行, 用于i,枚举(数据集)中的数据: 文件“ / home / khaled / Repositories / APDrawingGAN2 / data / init .py”,第72行,在ITER 对于i,在枚举数据(self.dataloader): 文件“/usr/local/lib/python3.8/dist-packages/torch/utils/data/dataloader.py”,线路345,在下一个 数据=自._next_data() 文件“ /usr/local/lib/python3.8/dist-packages/torch/utils/data/dataloader.py”,行856,在_next_data 返回自身。_process_data(data) 文件“ / usr / local /lib/python3.8/dist-packages/torch/utils/data/dataloader.py“,第881行,位于_process_data data.reraise() 重新 升高文件“ /usr/local/lib/python3.8/dist-packages/torch/_utils.py”,行394提高self.exc_type(msg) TypeError:在DataLoader工作进程0中捕获到TypeError。 原始回溯(大部分最近一次通话结束): 文件“ /usr/local/lib/python3.8/dist-packages/torch/utils/data/_utils/worker.py”,行178,在_worker_loop中, 数据= fetcher.fetch(index), 文件“ /usr/local/lib/python3.8/dist-packages/torch/utils/data/_utils/fetch.py“,第44行,在fetch data = [self.dataset [idx]中,可能是_batched_index中的idx 文件] usr / local / lib / python3.8 / dist-packages / torch / utils / data / _utils / fetch.py“,第44行, 数据= [self.dataset [idx],可能为_batched_index中的idx] 文件“ /home/khaled/Repositories/APDrawingGAN2/data/singledataset.py”,第98行,位于getitem item [regions [i] +' A'] = A [:,center [i,1] -rhs [i] / 2:center [i,1] + rhs [i] / 2,center [i,0] -rws [i] / 2:center [i,0] + rws [i] / 2] TypeError:仅整数张量单个元素的可以转换为索引
have you solved it, i have the same question
Trying to downgrade pytorch.
have you solved it, i have the same question。
@chinacharlie I haven't, sorry
trycenter[i,1].item()
, i guess the reason is that center[i,1]
is not int type
And i use the environment totally same with the requirement of this repository. and it can run successfully.
if you meets more bugs later, just use int() to transform float index to int
I have converted the tensors to ints as stated here wherever necessary if it saves anyone a bit of time: https://github.com/winfried-loetzsch/APDrawingGAN2
Thanks for the replies! The code was run in python2, when run in python3 leads to this error. Here is a commit in another repository to solve this error: https://github.com/yiranran/APDrawingGAN/commit/bc10583a244620325c6e4874566112ebbf5d2c7d
Error output
How to reproduce
Environment