How to save the attention weight in official Hgt model example

I’ve successfully train the hgt model on my dataset, but haven’t figured out how to save the attention weights and updated node features from the official hgt model tutorials

Do you mean you want to save the attention scores and node features of each intermediate layer? In that case, you can modify the HGTLayer a little bit to include attn_score in its output.

Then group the intermediate output into a list during layer-wise forward

all_layer_h, all_layer_attn_score = [], []
for i in range(self.n_layers):
    h, attn_score = self.gcs[i](G, h)

Thanks for the reply .I want to save the node features and attention attn_score in original graph,so at the end of training, it is straightforward to get the updated node weights and the attention scores on each edge.What am I supposed to do?

Hi @EverOasis , could you please elaborate more on what you want? I feel @dyru 's answer is already able to achieve that.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.