GentleZhu/HEER

TypeError: len() of a 0-d tensor with python2.7+pytorch0.4

Closed this issue · 2 comments

mldl@ub1604:/ub16_prj/HEER$ ./src/run.sh yago_ko_0.4 61
===Constructing Training Net===
{'PR': 368978, 'AD': 370617, 'WO': 284765, 'sum': 499584, 'AS': 350981, 'PE': 0, 'EV': 495520, 'PO': 495244}
[66501, 282506, 238013, 73510, 41629, 14615, 209572, 21624, 55856, 13644, 12898, 7326, 13325, 21929, 1184, 13867, 3527, 11700, 3808, 5427, 3414, 1570, 1852, 405]
===HEER Training===
{'nodes': ['PE', 'WO', 'AS', 'PR', 'AD', 'PO', 'EV'], 'edges': [[0, 1, 0], [0, 2, 0], [0, 2, 0], [0, 1, 0], [0, 3, 0], [0, 4, 0], [4, 4, 1], [0, 4, 0], [0, 4, 0], [0, 1, 0], [0, 4, 0], [0, 0, 1], [0, 0, 0], [0, 1, 0], [0, 5, 0], [0, 0, 1], [2, 4, 0], [0, 2, 0], [0, 0, 0], [6, 4, 0], [0, 1, 0], [0, 4, 0], [0, 0, 1], [4, 4, 1]], 'types': [':u', ':u', ':u', ':u', ':u', ':u', ':d', ':u', ':u', ':u', ':u', ':d', ':u', ':u', ':u', ':d', ':u', ':u', ':u', ':u', ':u', ':u', ':d', ':d']}
{'PR': 368978, 'AD': 370617, 'WO': 284765, 'sum': 499584, 'AS': 350981, 'PE': 0, 'EV': 495520, 'PO': 495244}
pre-train embedding loaded!
Traceback (most recent call last):
File "./src/main.py", line 160, in
main(args)
File "./src/main.py", line 136, in main
learn_embeddings()
File "./src/main.py", line 117, in learn_embeddings
model.train()
File "/home/mldl/ub16_prj/HEER/src/emb_lib.py", line 83, in train
loss, pure_loss = self.neg_loss(inputs, labels, self.neg_ratio)
File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/module.py", line 491, in call
result = self.forward(*input, **kwargs)
File "/home/mldl/ub16_prj/HEER/src/neg.py", line 145, in forward
if len(indices) == 0:
File "/usr/local/lib/python2.7/dist-packages/torch/tensor.py", line 349, in len
raise TypeError("len() of a 0-d tensor")
TypeError: len() of a 0-d tensor
mldl@ub1604:
/ub16_prj/HEER$

mldl@ub1604:~/ub16_prj/HEER$ ./src/run.sh dblp_ko_0.4 61
===Constructing Training Net===

{'A': 1736103, 'sum': 2812870, 'P': 0, 'W': 2502031, 'V': 2805369, 'Y': 2812808}
[2790361, 3906998, 7664894, 956991, 956787]
===HEER Training===
{'nodes': ['P', 'A', 'W', 'V', 'Y'], 'edges': [[0, 1, 0], [0, 0, 1], [0, 2, 0], [0, 3, 0], [0, 4, 0]], 'types': ['PA:u', 'PP:d', 'PW:u', 'PV:u', 'PY:u']}
{'A': 1736103, 'sum': 2812870, 'P': 0, 'W': 2502031, 'V': 2805369, 'Y': 2812808}
pre-train embedding loaded!
Traceback (most recent call last):
File "./src/main.py", line 160, in
main(args)
File "./src/main.py", line 136, in main
learn_embeddings()
File "./src/main.py", line 117, in learn_embeddings
model.train()
File "/home/mldl/ub16_prj/HEER/src/emb_lib.py", line 83, in train
loss, pure_loss = self.neg_loss(inputs, labels, self.neg_ratio)
File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/module.py", line 491, in call
result = self.forward(*input, **kwargs)
File "/home/mldl/ub16_prj/HEER/src/neg.py", line 145, in forward
if len(indices) == 0:
File "/usr/local/lib/python2.7/dist-packages/torch/tensor.py", line 349, in len
raise TypeError("len() of a 0-d tensor")
TypeError: len() of a 0-d tensor
mldl@ub1604:/ub16_prj/HEER$
mldl@ub1604:
/ub16_prj/HEER$

The problem is caused by new squeeze() function in pytorch 0.4.1. It has been resolved. Please pull down the latest version.