awslabs / dgl-lifesci

Python package for graph neural networks in chemistry and biology
Apache License 2.0
714 stars 147 forks source link

Masks in Meter.update() #143

Open and-tos opened 3 years ago

and-tos commented 3 years ago

Hi, I'm trying to use masks for multi task learning. The documentation in eval.py about the use of masks is not clear to me.

mask : None or float32 tensor
            Binary mask indicating the existence of ground truth labels with
            shape ``(B, T)``. If None, we assume that all labels exist and create
            a one-tensor for placeholder.

If a mask is set to 1 it could mean that a) the label will be masked or b) the label is present. Which one is it?

If label = [5, None, None], should I set mask = [1,0,0] or [0,1,1]

What's the convention if I wanted to exclude the "None" labels from the loss calculation?

Thanks a lot for clarifying!

mufeili commented 3 years ago

1 indicates the existence of a label. In your example, it will be [1, 0, 0]. For loss computation, we can multiply the prediction by the mask so that we will only update the model based on existing labels.