twjiang / graphSAGE-pytorch

A PyTorch implementation of GraphSAGE. This package contains a PyTorch implementation of GraphSAGE.
621 stars 150 forks source link

File not found error. #15

Closed DavidVillaHMD closed 2 years ago

DavidVillaHMD commented 4 years ago

Hi! I just cloned the repository and run it. After one whole epoch, I received an error, which says that: FileNotFoundError: [Errno 2] No such file or directory: 'models/model_best_debug_ep0_0.8758.torch' Here's the command to run it: python -m src.main --epochs 50 --cuda --learn_method unsup And here is the copy of error info: Step [68/68], Loss: 0.0432, Dealed Nodes [1355/1355] Validation F1: 0.8913525498891351 Test F1: 0.8758314855875832 Traceback (most recent call last): File "/home/huangmd/anaconda3/lib/python3.7/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "/home/huangmd/anaconda3/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/home/huangmd/graphSAGE-pytorch/src/main.py", line 76, in args.max_vali_f1 = evaluate(dataCenter, ds, graphSage, classification, device, args.max_vali_f1, args.name, epoch) File "/home/huangmd/graphSAGE-pytorch/src/utils.py", line 52, in evaluate torch.save(models, 'models/modelbest{}ep{}{:.4f}.torch'.format(name, cur_epoch, test_f1)) File "/home/huangmd/anaconda3/lib/python3.7/site-packages/torch/serialization.py", line 327, in save with _open_file_like(f, 'wb') as opened_file: File "/home/huangmd/anaconda3/lib/python3.7/site-packages/torch/serialization.py", line 212, in _open_file_like return _open_file(name_or_buffer, mode) File "/home/huangmd/anaconda3/lib/python3.7/site-packages/torch/serialization.py", line 193, in init super(_open_file, self).init(open(name, mode)) FileNotFoundError: [Errno 2] No such file or directory: 'models/model_best_debug_ep0_0.8758.torch'.

I run this repo under torch 1.4.0; python 3.7; ubuntu 18.04 with 2080ti. Hoping for a solution to this issue, thx!

zhao-tong commented 4 years ago

Hi, did you try creating a folder with name models?

DavidVillaHMD commented 4 years ago

Hi, did you try creating a folder with name models?

I did make such a folder, and the issue only happens under unsupervised learning. It's still unsolved.

hzzzzjzyq commented 3 years ago

create models at graphSAGE-pytorch-master not src may do

DavidVillaHMD commented 3 years ago

create models at graphSAGE-pytorch-master not src may do

Actually I just comment all lines about load and save model, and it works. This issue may happen when code we save torch by objact model. If saved by state_dict of model, no such issue will happen again. Like:

torch.save(graphSage.state_dict(), path1)
torch.save(classification.state_dict(), path2)
alkjoj commented 3 years ago

1.create models at graphSAGE-pytorch-master not src

  1. change the code into torch.save(models, '../models/modelbest{}ep{}{:.4f}.torch'.format(name, cur_epoch, test_f1))