Skip to content

temperature scaling #1

@Lyttonkeepfoing

Description

@Lyttonkeepfoing

It's a really nice repo. I read your paper and wondering the baseline you set is MSP+Temperature Scaling?
But I could not find the Temperture Scaling operations in your code.
parser.add_argument('--cwd_weight', default=0.1, type=float, help='Trianing time tempscaling') the option here
class KDLoss(nn.Module):
def init(self, temp_factor):
super(KDLoss, self).init()
self.temp_factor = temp_factor
self.kl_div = nn.KLDivLoss(reduction="sum")

def forward(self, input, target):
    log_p = torch.log_softmax(input/self.temp_factor, dim=1)
    q = torch.softmax(target/self.temp_factor, dim=1)
    loss = self.kl_div(log_p, q)*(self.temp_factor**2)/input.size(0)
    return loss

kdloss = KDLoss(2.0) the KDL loss here.
And Temperre Scaling is used in training time not inference? You said it's a post-hoc method, so you should use it in your inference time? Could you help me with this confusion?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions