rampasek / GraphGPS

Recipe for a General, Powerful, Scalable Graph Transformer
MIT License
643 stars 114 forks source link

error when running the code #21

Closed abdeljalil210 closed 1 year ago

abdeljalil210 commented 1 year ago

first of all, i thank you for this code wonderful, i have this error when running it: (graphgps) abdel@abdel-Latitude-5300-2-in-1:~/Downloads/GraphGPS-main$ python main.py --cfg configs/GPS/zinc-GPS+RWSE.yaml wandb.use False [] Run ID 0: seed=0, split_index=0 Starting now: 2022-12-27 13:48:05.514160 [] Loaded dataset 'Cora' from 'PyG': Data(x=[2708, 1433], edge_index=[2, 10556], y=[2708], train_mask=[2708], val_mask=[2708], test_mask=[2708]) undirected: True num graphs: 1 avg num_nodes/graph: 2708 num node features: 1433 num edge features: 0 num classes: 7 Traceback (most recent call last): File "/home/abdel/Downloads/GraphGPS-main/main.py", line 139, in loaders = create_loader() File "/home/abdel/mambaforge/envs/graphgps/lib/python3.9/site-packages/torch_geometric/graphgym/loader.py", line 295, in create_loader dataset = create_dataset() File "/home/abdel/mambaforge/envs/graphgps/lib/python3.9/site-packages/torch_geometric/graphgym/loader.py", line 226, in create_dataset dataset = load_dataset() File "/home/abdel/mambaforge/envs/graphgps/lib/python3.9/site-packages/torch_geometric/graphgym/loader.py", line 171, in load_dataset dataset = func(format, name, dataset_dir) File "/home/abdel/Downloads/GraphGPS-main/graphgps/loader/master_loader.py", line 212, in load_dataset_master prepare_splits(dataset) File "/home/abdel/Downloads/GraphGPS-main/graphgps/loader/split_generator.py", line 21, in prepare_splits setup_random_split(dataset) File "/home/abdel/Downloads/GraphGPS-main/graphgps/loader/split_generator.py", line 118, in setup_random_split set_dataset_splits(dataset, [train_index, val_index, test_index]) File "/home/abdel/Downloads/GraphGPS-main/graphgps/loader/split_generator.py", line 145, in set_dataset_splits mask = index2mask(split_index, size=dataset.data.y.shape[0]) File "/home/abdel/mambaforge/envs/graphgps/lib/python3.9/site-packages/torch_geometric/utils/mask.py", line 15, in index_to_mask index = index.view(-1) TypeError: Cannot interpret '-1' as a data type

abdeljalil210 commented 1 year ago

my version of torch is 1.10.2

rampasek commented 1 year ago

Hi @abdeljalil210, I’m sorry for a late response -- I think I answered you on Slack earlier, but pasting the answer here for anyone else.

From what I can tell you are trying to run the GPS on a transductive semi-supervised dataset (Cora) that is only a single graph. The GPS code is not set up for that type of learning, as it may require batching of that one large graph. For Cora, the graph is small enough to run it “full batch” but that is not what is currently supported. Right now the code is meant for inductive learning, where you have a training set of graphs and a validation/test set of graphs.

Best, Ladislav

rampasek commented 1 year ago

Update: In the PR #23 I added configs for 6 transductive datasets (Actor, Cornell, Texas, Wisconsin, Squirrel, Chameleon) to train GPS or Graphormer on. So running it on Cora is possible as well. For larger graphs, SAINT-like subsampling is available (provided through GraphGym).

However, note, that the performance is not competitive with specialized SOTA models. More details and discussion can be found in Section 4.2 of our upcoming survey paper: https://github.com/luis-mueller/probing-graph-transformers