the purpose of mask
Can you explain the purpose or effect of mask in the function "_get_neighbors_and_masks()" of model.py?
specifically for the following two lines of codes?
mask = neighbor_edges - train_edges # [batch_size, -1]
mask = (mask != 0).float()
it is an excellent job of your work ,hope your reply,thanks.
Hi! Thanks for your interest in our work. The code here is to get the neighbor information for a given pair (h, t). Since the (h, t) pair comes from training data, there must exist a triplet (h, r, t), which means that there exists an edge between h and t in our constructed graph. When we aggregate neighborhood information for h and t, we should not take this r edge into account, because r is exactly the target we are going to predict. Saying this from another perspective, when you do inference for a given pair (h, t), there is no edge between (h, t) and you are going to predict the edge. Therefore, when we are training the model for (h, t) we should also treat the r edge unseen to "mimic" the inference setting. The mask variable here is exactly to remove the ground-truth r edge from neighbors of (h, t).