-
Notifications
You must be signed in to change notification settings - Fork 387
Chapter09/Semantic_Segmentation_with_U_Net.ipynb #79
Copy link
Copy link
Open
Description
log = Report(n_epochs)
for ex in range(n_epochs):
N = len(trn_dl)
for bx, data in enumerate(trn_dl):
loss, acc = train_batch(model, data, optimizer, criterion)
log.record(ex+(bx+1)/N, trn_loss=loss, trn_acc=acc, end='\r')
N = len(val_dl)
for bx, data in enumerate(val_dl):
loss, acc = validate_batch(model, data, criterion)
log.record(ex+(bx+1)/N, val_loss=loss, val_acc=acc, end='\r')
log.report_avgs(ex+1)
RuntimeError: only batches of spatial targets supported (3D tensors) but got targets of size: : [4, 224, 224, 3]
in UnetLoss(preds, targets)
1 ce = nn.CrossEntropyLoss()
2 def UnetLoss(preds, targets):
----> 3 ce_loss = ce(preds, targets)
4 acc = (torch.max(preds, 1)[1] == targets).float().mean()
5 return ce_loss, acc
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels