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

Errors with ICEWS18 scripts from top of repo #12

Closed AlexMRuch closed 5 years ago

AlexMRuch commented 5 years ago

Not sure if I'm missing something, but in RE-Net/data/ICEWS18/get_history_graph.py.py there are two load_quadruples functions that seem to do the same thing.

When I run python data/ICEWS18/get_history_graph.py from the top of the repo directory, I get the following error and traceback:

Traceback (most recent call last):
  File "data/ICEWS18/get_history_graph.py", line 112, in <module>
    train_data, train_times = load_quadruples('', 'train.txt')
  File "data/ICEWS18/get_history_graph.py", line 47, in load_quadruples
    with open(os.path.join(inPath, fileName), 'r') as fr:
FileNotFoundError: [Errno 2] No such file or directory: 'train.txt'

I get the same error with python data/ICEWS18/get_history.py:

Traceback (most recent call last):
  File "data/ICEWS18/get_history.py", line 86, in <module>
    train_data, train_times = load_quadruples('','train.txt')
  File "data/ICEWS18/get_history.py", line 42, in load_quadruples
    with open(os.path.join(inPath, fileName), 'r') as fr:
FileNotFoundError: [Errno 2] No such file or directory: 'train.txt'

Whereas running these scripts from the top of the directory with python data/ICEWS18/get_history.py, etc., does not work, running python get_history.py, etc. from within the data/ICEWS18/ directory is successful. You may want to update your preprocessing notes in https://github.com/INK-USC/re-net#train-and-test to tell people to navigate to the respective data folder first and then run the python script.

Thanks for making this code public!

AlexMRuch commented 5 years ago

Also, when running python train.py -d ICEWS18/ --gpu 1 --model 3 --dropout 0.5 --n-hidden 200 --lr 1e-3 --max-epochs 20 --batch-size 1024 from the top of the repo, I got an FileNotFoundError: [Errno 2] No such file or directory: 'models/ICEWS18/rgcn.pth' error.

Any ideas?

Traceback:

/home/amruch/.local/lib/python3.6/site-packages/sklearn/externals/joblib/externals/cloudpickle/cloudpickle.py:47: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
Namespace(batch_size=1024, dataset='ICEWS18/', dropout=0.5, gpu=1, grad_norm=1.0, lr=0.001, max_epochs=20, model=3, n_hidden=200, num_k=10, rnn_layers=1, seq_len=10)
start training...
/home/amruch/anaconda3/envs/pytorch/lib/python3.6/site-packages/dgl/base.py:18: UserWarning: Initializer is not set. Use zero initializer instead. To suppress this warning, use `set_initializer` to explicitly specify which initializer to use.
  warnings.warn(msg)
Epoch 0001 | Loss 14.0406 | time 760.5193
/home/amruch/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/functional.py:1332: UserWarning: nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.
  warnings.warn("nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.")
valid Hits (filtered) @ 1: 0.207555
valid Hits (filtered) @ 3: 0.302348
valid Hits (filtered) @ 10: 0.410349
valid MRR (filtered): 0.276984
valid MR (filtered): 1122.525351
valid Loss: 12.064144
Traceback (most recent call last):
  File "train.py", line 223, in <module>
    train(args)
  File "train.py", line 184, in train
    model_state_file)
  File "/home/amruch/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/serialization.py", line 218, in save
    return _with_file_like(f, "wb", lambda f: _save(obj, f, pickle_module, pickle_protocol))
  File "/home/amruch/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/serialization.py", line 141, in _with_file_like
    f = open(f, mode)
FileNotFoundError: [Errno 2] No such file or directory: 'models/ICEWS18/rgcn.pth'

Same happens with the mean approach:

(pytorch) amruch@wit:~/RE-Net$ python train.py -d ICEWS18/ --gpu 1 --model 1 --dropout 0.5 --n-hidden 200 --lr 1e-3 --max-epochs 20 --batch-size 1024
/home/amruch/.local/lib/python3.6/site-packages/sklearn/externals/joblib/externals/cloudpickle/cloudpickle.py:47: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
Namespace(batch_size=1024, dataset='ICEWS18/', dropout=0.5, gpu=1, grad_norm=1.0, lr=0.001, max_epochs=20, model=1, n_hidden=200, num_k=10, rnn_layers=1, seq_len=10)
start training...
Epoch 0001 | Loss 14.4376 | time 365.4315
/home/amruch/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/functional.py:1332: UserWarning: nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.
  warnings.warn("nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.")
valid Hits (filtered) @ 1: 0.206316
valid Hits (filtered) @ 3: 0.305294
valid Hits (filtered) @ 10: 0.413893
valid MRR (filtered): 0.277101
valid MR (filtered): 1123.005740
valid Loss: 12.170151
Traceback (most recent call last):
  File "train.py", line 223, in <module>
    train(args)
  File "train.py", line 192, in train
    model_state_file)
  File "/home/amruch/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/serialization.py", line 218, in save
    return _with_file_like(f, "wb", lambda f: _save(obj, f, pickle_module, pickle_protocol))
  File "/home/amruch/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/serialization.py", line 141, in _with_file_like
    f = open(f, mode)
FileNotFoundError: [Errno 2] No such file or directory: 'models/ICEWS18/mean.pth'
AlexMRuch commented 5 years ago

For what it's worth, I got the attention model training (and I believe testing too) by manually running mkdir ICEWS18/. Not sure if it would be best to mention one has to do that in the README.md or if you can run an os.mkdir() command in the training script.

AlexMRuch commented 5 years ago

Update: after successfully training and training the attention model from the top of the repo, running the same process for the RGCN aggregator failed during training with the following error:

Traceback (most recent call last):
  File "/home/amruch/RE-Net/test.py", line 147, in <module>
    test(args)
  File "/home/amruch/RE-Net/test.py", line 43, in test
    with open('../data/' + args.dataset+'/test_history_sub.txt', 'rb') as f:
FileNotFoundError: [Errno 2] No such file or directory: '../data/ICEWS18/test_history_sub.txt'

If I navigate to the data/ folder and run the same code (python3 /home/amruch/RE-Net/test.py -d ICEWS18 --gpu 1 --model 3 --n-hidden 200), then it throws this error:

Traceback (most recent call last):
  File "/home/amruch/RE-Net/test.py", line 147, in <module>
    test(args)
  File "/home/amruch/RE-Net/test.py", line 12, in test
    num_nodes, num_rels = utils.get_total_number('./data/' + args.dataset, 'stat.txt')
  File "/home/amruch/RE-Net/utils.py", line 9, in get_total_number
    with open(os.path.join(inPath, fileName), 'r') as fr:
FileNotFoundError: [Errno 2] No such file or directory: './data/ICEWS18/stat.txt'
AlexMRuch commented 5 years ago

I got the script closer to running by editing line ~43 in test.py to read

    if args.model == 3:
        with open('data/' + args.dataset+'/test_history_sub.txt', 'rb') as f:
            s_history_test_data = pickle.load(f)
        with open('data/' + args.dataset+'/test_history_ob.txt', 'rb') as f:
            o_history_test_data = pickle.load(f)

That then gave rise to this error:

start testing:
Using best epoch: 20
/home/amruch/anaconda3/envs/pytorch/lib/python3.6/site-packages/dgl/base.py:18: UserWarning: Initializer is not set. Use zero initializer instead. To suppress this warning, use `set_initializer` to explicitly specify which initializer to use.
  warnings.warn(msg)
/home/amruch/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/functional.py:1332: UserWarning: nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.
  warnings.warn("nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.")
Traceback (most recent call last):
  File "/home/amruch/RE-Net/test.py", line 147, in <module>
    test(args)
  File "/home/amruch/RE-Net/test.py", line 114, in test
    total_ranks_filter = np.concatenate((total_ranks_filter, ranks_filter))
UnboundLocalError: local variable 'ranks_filter' referenced before assignment

Found out that's because line 114 says anks_filter instead of ranks_filter, which was an easy fix

AlexMRuch commented 5 years ago

Got it running after making those fixes!

woojeongjin commented 5 years ago

Wow thanks for your corrections I updated the repo!

AlexMRuch commented 5 years ago

Glad to help!