Closed g-karthik closed 5 years ago
Ah, after a moderate dive through the code and printing relevant tensors, I'm guessing this is happening because lm_labels
has a bunch of -1s to mask the context (and the negative candidates) for the LM head, and that is throwing the Precision and Recall classes in pytorch-ignite off, unlike the CrossEntropyLoss class, which has ignore_index=-1
to handle the -1s.
I wonder if there's an equivalent for ignore_index
for Precision and Recall, or if I'd have to handle them by modifying the output_transform
lambda.
Created a transform function like I mentioned above for Precision
and Recall
and the error is gone!
def precision_recall_transform(x):
logits, labels = x[0][0], x[1][0]
condition = (labels != -1)
return logits[condition], labels[condition]
However, I see that the actual F1 scores computed this way are unusually low (like 0.015 instead of 0.15 -- the latter is what one would expect for unigram F1 for models like these based on what's reported in literature). Is this something others see as well?
Oh never mind, I realized what is computed by the Precision/Recall classes in ignite isn't really the unigram precision/recall I was looking to compute and it makes sense that they're unusually low.
https://github.com/huggingface/transfer-learning-conv-ai/blob/3bac4924fa307d5e4eba977818b2a29d403e8371/train.py#L235
So I tried extending the above metrics being computed during training to additionally compute validation set unigram precision, recall and F1 since these are supported in
pytorch-ignite
. I did something like the following:Does this seem right? @thomwolf
I'm getting a device-side assert failure with the following stack trace when I launch the distributed train job with
CUDA_LAUNCH_BLOCKING=1
:Any ideas on why this is happening?