Skip to content
Snippets Groups Projects
Commit 68d76e5f authored by umlauf's avatar umlauf
Browse files

CEL

parent 78e58818
No related branches found
No related tags found
No related merge requests found
......@@ -153,12 +153,19 @@ def train(model, name, seed,gradient_accumulation_steps,mixup, threshold, lambda
# return loss
#create one hot vector but still keeping the probs
# def cross_entropy(preds, target):
# target = torch.eye(preds.shape[1])[target.long()]
# log_preds = torch.log(preds)
# loss = -torch.mean(target * log_preds)
# return loss
def cross_entropy(preds, target):
target = torch.eye(preds.shape[1])[target.long()]
device = preds.device
target = torch.eye(preds.shape[1], device=device)[target.long()]
log_preds = torch.log(preds)
loss = -torch.mean(target * log_preds)
return loss
def mixup_function(batch_of_matrices, batch_of_labels, l, t):
runs = math.floor(batch_of_matrices.size()[0]/2)
counter=0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment