thu-coai / ConvLab-2

ConvLab-2: An Open-Source Toolkit for Building, Evaluating, and Diagnosing Dialogue Systems
Apache License 2.0
449 stars 130 forks source link

BERTNLU postprocess.py 为什么可以通过 if intent_logits[j] > 0: 来获得intent的预测呢? #235

Closed csmust closed 1 year ago

csmust commented 2 years ago
for j in range(dataloader.intent_dim):
    if intent_logits[j] > 0:   
        intent, domain, slot, value = re.split('\+', dataloader.id2intent[j])
        das.append([intent, domain, slot, value])
zqwerty commented 1 year ago

Sorry for the late reply. intent_logits are the logits before sigmoid layer, since BCEWithLogitsLoss combines a Sigmoid layer and the BCELoss in one single class. Therefore, the logit>0 means output after sigmoid is larger than 0.5. https://github.com/thu-coai/ConvLab-2/blob/ad32b76022fa29cbc2f24cbefbb855b60492985e/convlab2/nlu/jointBERT/jointBERT.py#L44