我试图通过Facebook Research复制Poincaré Embeddings for Learning Hierarchical Representations上的Github。但我无法运行example.sh
将哺乳动物的子树嵌入重建环境中。
操作系统:Ubuntu 16.04,使用 Anaconda 4.3.30, Python 3.6.5, Pytorch 0.4。 0
命令:NHTHREDS=2 ./example.sh
错误日志:
Using 2 threads
slurp: objects=1181, edges=6541
Indexing data
json_conf: {"distfn": "poincare", "dim": 5, "lr": 0.3, "batchsize": 10, "negs": 50}
Burnin: lr=0.003
'Traceback (most recent call last):\n File "/home/harman/anaconda3/envs/pytorch-venv/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 57, in _worker_loop\n samples = collate_fn([dataset[i] for i in batch_indices])\n File "/home/harman/anaconda3/envs/pytorch-venv/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 57, in <listcomp>\n samples = collate_fn([dataset[i] for i in batch_indices])\n File "/home/harman/harman_workspace/poincare-embeddings/model.py", line 185, in __getitem__\n if n not in self._weights[t]:\nKeyError: tensor(491)\n'
Traceback (most recent call last):
File "/home/harman/harman_workspace/poincare-embeddings/train.py", line 19, in train_mp
train(model, data, optimizer, opt, log, rank, queue)
File "/home/harman/harman_workspace/poincare-embeddings/train.py", line 46, in train
for inputs, targets in loader:
File "/home/harman/anaconda3/envs/pytorch-venv/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 286, in __next__
return self._process_next_batch(batch)
File "/home/harman/anaconda3/envs/pytorch-venv/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 307, in _process_next_batch
raise batch.exc_type(batch.exc_msg)
KeyError: 'Traceback (most recent call last):\n File "/home/harman/anaconda3/envs/pytorch-venv/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 57, in _worker_loop\n samples = collate_fn([dataset[i] for i in batch_indices])\n File "/home/harman/anaconda3/envs/pytorch-venv/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 57, in <listcomp>\n samples = collate_fn([dataset[i] for i in batch_indices])\n File "/home/harman/harman_workspace/poincare-embeddings/model.py", line 185, in __getitem__\n if n not in self._weights[t]:\nKeyError: tensor(491)\n'
'Traceback (most recent call last):\n File "/home/harman/anaconda3/envs/pytorch-venv/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 57, in _worker_loop\n samples = collate_fn([dataset[i] for i in batch_indices])\n File "/home/harman/anaconda3/envs/pytorch-venv/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 57, in <listcomp>\n samples = collate_fn([dataset[i] for i in batch_indices])\n File "/home/harman/harman_workspace/poincare-embeddings/model.py", line 185, in __getitem__\n if n not in self._weights[t]:\nKeyError: tensor(491)\n'
Traceback (most recent call last):
File "/home/harman/harman_workspace/poincare-embeddings/train.py", line 19, in train_mp
train(model, data, optimizer, opt, log, rank, queue)
File "/home/harman/harman_workspace/poincare-embeddings/train.py", line 46, in train
for inputs, targets in loader:
File "/home/harman/anaconda3/envs/pytorch-venv/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 286, in __next__
return self._process_next_batch(batch)
File "/home/harman/anaconda3/envs/pytorch-venv/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 307, in _process_next_batch
raise batch.exc_type(batch.exc_msg)
KeyError: 'Traceback (most recent call last):\n File "/home/harman/anaconda3/envs/pytorch-venv/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 57, in _worker_loop\n samples = collate_fn([dataset[i] for i in batch_indices])\n File "/home/harman/anaconda3/envs/pytorch-venv/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 57, in <listcomp>\n samples = collate_fn([dataset[i] for i in batch_indices])\n File "/home/harman/harman_workspace/poincare-embeddings/model.py", line 185, in __getitem__\n if n not in self._weights[t]:\nKeyError: tensor(491)\n'
任何帮助将不胜感激。
答案 0 :(得分:0)
我有同样的错误。它是关于关键错误的版本。 https://github.com/facebookresearch/poincare-embeddings/issues/12
这是解决方案,他们回答了关于h,w,t改变int 我尝试了但失败了,并将火炬1.0.0的版本降低到0.3.1。成功了。
希望解决问题