add loss container

This commit is contained in:
2020-10-11 23:09:04 +08:00
parent 6070f08835
commit 436bca88b4
3 changed files with 26 additions and 11 deletions

9
engine/util/container.py Normal file
View File

@@ -0,0 +1,9 @@
class LossContainer:
def __init__(self, weight, loss):
self.weight = weight
self.loss = loss
def __call__(self, *args, **kwargs):
if self.weight > 0:
return self.weight * self.loss(*args, **kwargs)
return 0.0