无法运行Poincare Embeddings示例来获取分层表示

问题描述 投票:2回答:1

我试图通过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'

任何帮助将不胜感激。

python hierarchical-data word-embedding
1个回答
0
投票

我有同样的错误。这是关键错误的版本。 https://github.com/facebookresearch/poincare-embeddings/issues/12

这里是解决方案,他们回答了改变关于h,w,t我试过但失败了,并尝试将火炬1.0.0的版本降低到0.3.1。它成功了。

希望能解决问题

© www.soinside.com 2019 - 2024. All rights reserved.