HennyJie / BrainGB

Officially Accepted to IEEE Transactions on Medical Imaging (TMI, IF: 11.037) - Special Issue on Geometric Deep Learning in Medical Imaging.
MIT License
165 stars 42 forks source link

IndexError #19

Open fatemehghanadi opened 8 months ago

fatemehghanadi commented 8 months ago

Hello. when i run this code on cuda environment this error happend. would you please help me fixing it? python -m examples.example_main --dataset_name ABIDE --pooling concat --gcn_mp_type edge_node_concate --hidden_dim 256


(base) C:\Users\Tandi\Downloads\BrainGB>python -m examples.example_main --dataset_name ABIDE --pooling concat --gcn_mp_type edge_node_concate --hidden_dim 256
Processing...
Done!
seed for seed_everything(): 767955
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\Tandi\Downloads\BrainGB\examples\example_main.py", line 149, in <module>
    main(parser.parse_args())
  File "C:\Users\Tandi\Downloads\BrainGB\examples\example_main.py", line 69, in main
    train_set, test_set = dataset[train_index], dataset[test_index]
                          ~~~~~~~^^^^^^^^^^^^^
  File "C:\Users\Tandi\anaconda3\Lib\site-packages\torch_geometric\data\dataset.py", line 268, in __getitem__
    return self.index_select(idx)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Tandi\anaconda3\Lib\site-packages\torch_geometric\data\dataset.py", line 306, in index_select
    raise IndexError(
IndexError: Only slices (':'), list, tuples, torch.tensor and np.ndarray of dtype long or bool are valid indices (got 'ndarray')
GiDunPar commented 7 months ago

In ndarray, you need to change it to int64. You can modify the data type yourself. I hope it will be helpful to you.

Gemaxis commented 4 weeks ago

One simple way: train_set, test_set = dataset[train_index.tolist()], dataset[test_index.tolist()]