You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
415 B
Python
17 lines
415 B
Python
9 months ago
|
# -*- coding: utf-8 -*-
|
||
|
# @Time : 2020/6/5 11:36
|
||
|
# @Author : zhoujun
|
||
|
import copy
|
||
|
from .DB_loss import DBLoss
|
||
|
|
||
|
__all__ = ["build_loss"]
|
||
|
support_loss = ["DBLoss"]
|
||
|
|
||
|
|
||
|
def build_loss(config):
|
||
|
copy_config = copy.deepcopy(config)
|
||
|
loss_type = copy_config.pop("type")
|
||
|
assert loss_type in support_loss, f"all support loss is {support_loss}"
|
||
|
criterion = eval(loss_type)(**copy_config)
|
||
|
return criterion
|