INK-USC / RE-Net

Recurrent Event Network: Autoregressive Structure Inference over Temporal Knowledge Graphs (EMNLP 2020)
http://inklab.usc.edu/renet/
436 stars 95 forks source link

TypeError in pretrain.py #24

Closed NetherNova closed 4 years ago

NetherNova commented 4 years ago

torch.version 1.3.1 dgl.version 0.4.2

Calling in ./data/ICEWS14: python get_history_graph.py seems to work

However: python3 pretrain.py -d ICEWS14

Namespace(batch_size=1024, dataset='ICEWS14', dropout=0.5, gpu=0, grad_norm=1.0, lr=0.01, max_epochs=100, maxpool=1, model=0, n_hidden=200, num_k=10, rnn_layers=1, seq_len=10) start training... Traceback (most recent call last): File "pretrain.py", line 139, in train(args) File "pretrain.py", line 83, in train loss = model(batch_data, true_s, true_o, graph_dict) File "/home/martin/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py", line 541, in call result = self.forward(*input, *kwargs) File "/home/RE-Net-master/global_model.py", line 47, in forward packed_input = self.aggregator(sorted_t, self.ent_embeds, graph_dict, reverse=reverse) File "/home/martin/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py", line 541, in call result = self.forward(input, **kwargs) File "/home/RE-Net-master/Aggregator.py", line 38, in forward time_list.append(torch.LongTensor(times[length - self.seq_len:length])) TypeError: only integer tensors of a single element can be converted to an index

Seems to be the same as: #22

ngl567 commented 4 years ago

I have the same issue.

yuhaoha commented 4 years ago

add this line: length = int(length) after length = tim / time_unit(line 36) maybe work