Deep Learning, Pytorch, Fine Tuning, Computer Vision, Transfer Learning.
CustomLoss(torch.nn.Module): def __init__(self, class_weights): super(CustomLoss, self).__init__() self.class_weights = class_weights def forward(self, inputs, targets): ce_loss = F.cross_entropy(inputs, targets, reduction='none') weights = torch.ones_like(targets).float() for class_idx, weight in