Logits和Logistic回归是一回事吗?

问题描述

我有以下代码用于预测文本相似度:

text_A = 'Some sentence .'
text_B = 'Another sentence .'

encoded_inputs = tokenizer.encode_plus(text_A,text_B,add_special_tokens=True,return_token_type_ids=True)
subwords,token_type_ids = encoded_inputs["input_ids"],encoded_inputs["token_type_ids"]

subwords = torch.LongTensor(subwords).view(1,-1).to(model.device)
token_type_ids = torch.LongTensor(token_type_ids).view(1,-1).to(model.device)

logits = model(subwords,token_type_ids)[0]
label = torch.topk(logits,k=1,dim=-1)[1].squeeze().item()

print(f'Text A: {text_A}')
print(f'Text B: {text_B}')
print(f'Label : {i2w[label]} ({F.softmax(logits,dim=-1).squeeze()[label] * 100:.3f}%)')

当我打印logits变量时,它给出的输出类似于[-0.4221,0.9551],因此我得出结论,logits变量存储原始预测值(称为logits) 将被传递给标准化函数,例如softmax

但是,令我困惑的是,logits和logistic回归是否相同?我只是无法断定上面的代码仅使用logits 还是使用logistic回归来预测文本相似性的可能性。有人对此有明确的答案吗?

谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)