MCPcopy Create free account
hub / github.com/OpenBMB/DecT / normalize

Method normalize

src/dect_verbalizer.py:199–211  ·  view source on GitHub ↗

Given logits regarding the entire vocabulary, return the probs over the label words set. Args: logits (:obj:`Tensor`): The logits over the entire vocabulary. Returns: :obj:`Tensor`: The logits over the label words set.

(self, logits: torch.Tensor)

Source from the content-addressed store, hash-verified

197 return label_logits
198
199 def normalize(self, logits: torch.Tensor) -> torch.Tensor:
200 """
201 Given logits regarding the entire vocabulary, return the probs over the label words set.
202
203 Args:
204 logits (:obj:`Tensor`): The logits over the entire vocabulary.
205
206 Returns:
207 :obj:`Tensor`: The logits over the label words set.
208
209 """
210 batch_size = logits.shape[0]
211 return F.softmax(logits.reshape(batch_size, -1), dim=-1).reshape(*logits.shape)
212
213
214 def aggregate(self, label_words_logits: torch.Tensor) -> torch.Tensor:

Callers 1

simMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected