Correct way of normalizing the node features #4381
Answered
by
rusty1s
SaffronWolf
asked this question in
Q&A
-
I am working on graph classification problem and was wondering how to normalize node features. Are they supposed to be normalized individually or for entire graph at a time? Also, how do you ensure the same behavior at inference? |
Beta Was this translation helpful? Give feedback.
Answered by
rusty1s
Mar 31, 2022
Replies: 1 comment 2 replies
-
You should calculate mean and standard deviation of node features across all nodes in all training graphs: mean = train_dataset.data.x.mean(dim=0, keepdim=True)
std = train_dataset.data.x.std(dim=0, keepdim=True) You can then apply normalization within every graph: data.x = (data.x - mean) / std |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
SaffronWolf
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should calculate mean and standard deviation of node features across all nodes in all training graphs:
You can then apply normalization within every graph: