Problems with custom loss functions #444
cyhltsrjyyc
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to use a custom loss function which needs other inputs, the loss function is showed as follow:
class CustomLoss(nn.Module):
def init(self, teacher_preds_2, teacher_preds_3, teacher_preds_4):
super(CustomLoss, self).init()
self.teacher_preds_2 = torch.tensor(teacher_preds_2, requires_grad=True)
self.teacher_preds_3 = torch.tensor(teacher_preds_3, requires_grad=True)
self.teacher_preds_4 = torch.tensor(teacher_preds_4, requires_grad=True)
The "teacher_preds_2, teacher_preds_3, teacher_preds_4" are three fixed tensors with the same size as the training sample. How can I get the batch of the three tensors and calculate the R2 between them and y_pred during fit process?
Beta Was this translation helpful? Give feedback.
All reactions