pyg-team / pytorch_geometric

Graph Neural Network Library for PyTorch
https://pyg.org
MIT License
21.11k stars 3.63k forks source link

Data object allows numpy values but doesn't actually support it #2111

Open richardrl opened 3 years ago

richardrl commented 3 years ago
  1. Generate a dictionary where the values are numpy arrays.
  2. Load this into a Data object with Data.from_dict.

Ostensibly, we now have a valid data object. But none of the subsequent operations over this object are supported when there are numpy arrays.

For example, in line 204 of torch_geometric/data/data.py, there is a line:

item.size(...)

This will fail if item is a numpy array, and succeed if item is a torch tensor.

rusty1s commented 3 years ago

That is intended. All tensor data should be saved as PyTorch tensors.

richardrl commented 3 years ago

@rusty1s Alright, but it could be helpful to have an assertion or check for whether the input is a torch tensor. it was tricky to trace this error

rusty1s commented 3 years ago

You are right. I will add that in.