Open dosonleung opened 5 years ago
I encountered this problem a few minutes ago. I was on PyTorch 1.0, and I found that downgrading to PyTorch 0.4.1 makes it work.
It's fixed in this commit so pull the latest version.
After reading Get the mean from a list of tensors, it seems like caused by the 0-dim tensor in PyTorch 1.0 (again)
I like your code very much but i met this issue. when i tyed: python supervised.py --src_lang ja --tgt_lang en --src_emb data/wiki.ja.vec --tgt_emb data/wiki.en.vec --n_refinement 5 --dico_train data/ja-en-train.text --dico_eval data/ja-en-test.text --emb_dim 300 the info came:
INFO - 01/19/19 12:37:04 - 0:00:00 - ============ Initialized logger ============ INFO - 01/19/19 12:37:04 - 0:00:00 - cuda: True dico_build: S2T&T2S dico_eval: data/ja-en-test.text dico_max_rank: 10000 dico_max_size: 0 dico_method: csls_knn_10 dico_min_size: 0 dico_threshold: 0 dico_train: data/ja-en-train.text emb_dim: 300 exp_id: exp_name: debug exp_path: /root/MUSE/dumped/debug/w0sel06ppf export: txt max_vocab: 200000 n_refinement: 5 normalize_embeddings: seed: -1 src_emb: data/wiki.ja.vec src_lang: ja tgt_emb: data/wiki.en.vec tgt_lang: en verbose: 2 INFO - 01/19/19 12:37:04 - 0:00:00 - The experiment will be stored in /root/MUSE/dumped/debug/w0sel06ppf INFO - 01/19/19 12:37:19 - 0:00:15 - Loaded 200000 pre-trained word embeddings. INFO - 01/19/19 12:37:42 - 0:00:39 - Loaded 200000 pre-trained word embeddings. INFO - 01/19/19 12:37:44 - 0:00:40 - Found 6819 pairs of words in the dictionary (4436 unique). 0 other pairs contained at least one unknown word (0 in lang1, 0 in lang2) INFO - 01/19/19 12:37:44 - 0:00:41 - Validation metric: precision_at_1-csls_knn_10 INFO - 01/19/19 12:37:44 - 0:00:41 - Starting iteration 0... INFO - 01/19/19 12:37:45 - 0:00:41 - Found 1952 pairs of words in the dictionary (1451 unique). 0 other pairs contained at least one unknown word (0 in lang1, 0 in lang2) Traceback (most recent call last): File "supervised.py", line 101, in
evaluator.all_eval(to_log)
File "/root/MUSE/src/evaluation/evaluator.py", line 217, in all_eval
self.word_translation(to_log)
File "/root/MUSE/src/evaluation/evaluator.py", line 120, in word_translation
dico_eval=self.params.dico_eval
File "/root/MUSE/src/evaluation/word_translation.py", line 149, in get_word_translation_accuracy
precision_at_k = 100 * np.mean(list(matching.values()))
File "/root/anaconda3/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 2920, in mean
out=out, **kwargs)
File "/root/anaconda3/lib/python3.7/site-packages/numpy/core/_methods.py", line 85, in _mean
ret = ret.dtype.type(ret / rcount)
AttributeError: 'torch.dtype' object has no attribute 'type'
I will be great appreciate that if you can tell me how to solve this problem.Thx~