​语义分割损失函数​

x33g5p2x  于2021-11-12 转载在 其他  
字(0.6k)|赞(0)|评价(0)|浏览(491)

这里面有几个损失函数:

GitHub - MichaelFan01/STDC-Seg: Source Code of our CVPR2021 paper "Rethinking BiSeNet For Real-time Semantic Segmentation"

损失函数代码: 

  1. #!/usr/bin/python
  2. # -*- encoding: utf-8 -*-
  3. import torch
  4. import torch.nn as nn
  5. import torch.nn.functional as F
  6. from loss.util import enet_weighing
  7. import numpy as np
  8. class OhemCELoss(nn.Module):
  9. def __init__(self, thresh, n_min, ignore_lb=255, *args, **kwargs):
  10. super(OhemCELoss, self).__init__()
  11. self.thresh = -torch.log(torch.tensor(thresh, dtype=torch.float)).cuda()
  12. self.n_min = n_min
  13. self.ignore_lb = ignore_lb
  14. self.criteria = nn.CrossEntropyLoss(ignore_index=ignore_lb, reduction

相关文章