Creating the graph dataset
The next step is to create a synthetic social network dataset to demonstrate our graph deep learning techniques. While real-world data would be ideal, using synthetic data allows us to focus on the implementation and understanding of the algorithms without the complexities of data acquisition and preprocessing.
Here, we will create a social network dataset representing university students. The complete code can be found at https://github.com/PacktPublishing/Applied-Deep-Learning-on-Graphs.
Let’s break down this code and explain each part.
- We set a random seed for reproducibility:
torch.manual_seed(42)
This ensures that we generate the same “random” data each time we run the code.
- We define our dataset parameters:
num_nodes = 1000 num_features = 10 num_classes = 5
num_nodes
is the number of students (nodes) in our network.num_features
is the number of features for each student. We’re using 10 features to represent age...