'How to change the node tensor type on an entire PyTorch Geometric Dataset?

Is there a function to change the tensor type (from long to float in my case) on the node features of every graph in a pytorch geometric dataset? Iterating over the dataset with

for graph in dataset:
    graph.x = graph.x.float()

does not work. It is possible to transform the dataset to a list and then use the approach above, but all dataset methods (e.g. shuffle) are lost in the process.

Is there a method to quickly transform the tensor types of every graph?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source