Dice coeff for batches
(input, target)
| 267 | |
| 268 | |
| 269 | def dice_coeff(input, target): |
| 270 | """Dice coeff for batches""" |
| 271 | if input.is_cuda: |
| 272 | s = torch.FloatTensor(1).to(device = input.device).zero_() |
| 273 | else: |
| 274 | s = torch.FloatTensor(1).zero_() |
| 275 | |
| 276 | for i, c in enumerate(zip(input, target)): |
| 277 | s = s + DiceCoeff().forward(c[0], c[1]) |
| 278 | |
| 279 | return s / (i + 1) |
| 280 | |
| 281 | |
| 282 |