daguan_2019_rank9
daguan_2019_rank9 copied to clipboard
你好,我想问一下linears.py里面的poolerstartlogits是什么用?
endlogits里面的soft_label为啥要加上num_label?
用的是logits,维度是num_labels大小,concat操作,所以加上num_labels个数
在 2020-03-31 16:31:22,"heroazhe" [email protected] 写道:
endlogits里面的soft_label为啥要加上num_label?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.
哦哦,代码我知道啥意思,但不知道原理,从网上没有搜到具体的原理,只知道这好像跟qa中的span有关系,了解start_logits和end_logits的计算方法我该怎么查?
------------------ 原始邮件 ------------------ 发件人: "lonePatient"<[email protected]>; 发送时间: 2020年3月31日(星期二) 下午5:17 收件人: "lonePatient/daguan_2019_rank9"<[email protected]>; 抄送: "FTD'2015"<[email protected]>;"Author"<[email protected]>; 主题: Re: [lonePatient/daguan_2019_rank9] 你好,我想问一下linears.py里面的poolerstartlogits是什么用? (#7)
用的是logits,维度是num_labels大小,concat操作,所以加上num_labels个数
在 2020-03-31 16:31:22,"heroazhe" <[email protected]> 写道:
endlogits里面的soft_label为啥要加上num_label?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
@heroazhe 很简单的一个想法啊,结束位置依赖于开始位置,很自然的将开始位置信息与文本语义向量结合作为结束预测的输入,那相当于有两种方式,直接hard label即argmax(logits),这种的话train时候hard label是真实的,但是预测的时候是argmax的,不一定正确,这个就像seq2seq里面的“Exposure @Bias”(好像那么一回事,呵呵瞎哔哔的),那么就可以使用soft label,即softmax预测的logits,这样train和test是同步的,当然可以折中,抽样,加一个概率判断是使用hard还是soft。
额,还是有点似懂非懂。 还有一个疑问是training的时候,有一句是如果为softlabel,则start_logits.scatter_(2, start_point.unsqueeze(2), 1) 这句话的意思应该是把对应的label位置标成1吧,这样的话其他的label还是为0,不还是hard label吗? ------------------ 原始邮件 ------------------ 发件人: "lonePatient"<[email protected]>; 发送时间: 2020年3月31日(星期二) 晚上6:00 收件人: "lonePatient/daguan_2019_rank9"<[email protected]>; 抄送: "FTD'2015"<[email protected]>;"Mention"<[email protected]>; 主题: Re: [lonePatient/daguan_2019_rank9] 你好,我想问一下linears.py里面的poolerstartlogits是什么用? (#7)
@heroazhe 很简单的一个想法啊,结束位置依赖于开始位置,很自然的将开始位置信息与文本语义向量结合作为结束预测的输入,那相当于有两种方式,直接hard label即argmax(logits),这种的话train时候hard label是真实的,但是预测的时候是argmax的,不一定正确,这个就像seq2seq里面的“Exposure @bias”(好像那么一回事,呵呵瞎哔哔的),那么就可以使用soft label,即softmax预测的logits,这样train和test是同步的,当然可以折中,抽样,加一个概率判断是使用hard还是soft。
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
还有那个output[0]的size是batch_sizeseq_lennum_labels吧? 我现在看了一个类似你这个的pytorch的代码,他里面是这么写的 def forward(self, input_ids, token_type_ids=None, attention_mask=None, start_positions=None,end_positions=None): outputs = self.bert(input_ids, token_type_ids, attention_mask) sequence_output = outputs[0] # batch * seq * hidden sequence_output = self.dropout(sequence_output) start_logits = self.start_fc(sequence_output) # 开始的信息 if start_positions is not None and self.training: if self.soft_label: batch_size = input_ids.size(0) seq_len = input_ids.size(1) label_logits = torch.FloatTensor(batch_size, seq_len, self.num_labels)
label_logits.zero_()
label_logits = label_logits.to(input_ids.device)
label_logits.scatter_(2, start_positions.unsqueeze(2), 1) # 按照start进行填充 start_position= batch_size*seq_len
else:
label_logits = start_positions.unsqueeze(2).float()
else:
label_logits = F.softmax(start_logits, -1) # batch_size * seq * num_labels
if not self.soft_label:
label_logits = torch.argmax(label_logits, -1).unsqueeze(2).float()
end_logits = self.end_fc(sequence_output, label_logits)
outputs = (start_logits, end_logits,) + outputs[2:]最后这个outputs是在干嘛? outputs的长度不应该是2吗? 越界了吧这都
------------------ 原始邮件 ------------------ 发件人: "lonePatient"<[email protected]>; 发送时间: 2020年3月31日(星期二) 晚上6:00 收件人: "lonePatient/daguan_2019_rank9"<[email protected]>; 抄送: "FTD'2015"<[email protected]>;"Mention"<[email protected]>; 主题: Re: [lonePatient/daguan_2019_rank9] 你好,我想问一下linears.py里面的poolerstartlogits是什么用? (#7)
@heroazhe 很简单的一个想法啊,结束位置依赖于开始位置,很自然的将开始位置信息与文本语义向量结合作为结束预测的输入,那相当于有两种方式,直接hard label即argmax(logits),这种的话train时候hard label是真实的,但是预测的时候是argmax的,不一定正确,这个就像seq2seq里面的“Exposure @bias”(好像那么一回事,呵呵瞎哔哔的),那么就可以使用soft label,即softmax预测的logits,这样train和test是同步的,当然可以折中,抽样,加一个概率判断是使用hard还是soft。
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
@heroazhe 不会吧的啊 ,你看下bert的输出
我又看了下代码,这里所谓的softlabel是在计算end_logits的时候加入了label的上下文信息,在计算loss的时候,target并没有softmax,还是one-hot的。 这种做法相当于加了一个crf吧,让模型学习到label的相关信息。 soft label应该针对的是计算ce时的target而不是logits吧?
------------------ 原始邮件 ------------------ 发件人: "lonePatient"<[email protected]>; 发送时间: 2020年3月31日(星期二) 晚上6:00 收件人: "lonePatient/daguan_2019_rank9"<[email protected]>; 抄送: "FTD'2015"<[email protected]>;"Mention"<[email protected]>; 主题: Re: [lonePatient/daguan_2019_rank9] 你好,我想问一下linears.py里面的poolerstartlogits是什么用? (#7)
@heroazhe 很简单的一个想法啊,结束位置依赖于开始位置,很自然的将开始位置信息与文本语义向量结合作为结束预测的输入,那相当于有两种方式,直接hard label即argmax(logits),这种的话train时候hard label是真实的,但是预测的时候是argmax的,不一定正确,这个就像seq2seq里面的“Exposure @bias”(好像那么一回事,呵呵瞎哔哔的),那么就可以使用soft label,即softmax预测的logits,这样train和test是同步的,当然可以折中,抽样,加一个概率判断是使用hard还是soft。
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
@heroazhe 还是那个问题啊 ,训练的时候标签是可知的,可用可不用,这里需呀做实验才知道哪种好,我这里可能是应该是为了应对eval使用soft label,将hard label转化为one-hot形式,纬度保持一致,具体的需要你个人做实验蔡得知。