summaryrefslogtreecommitdiff
path: root/become_yukarin/loss.py
diff options
context:
space:
mode:
Diffstat (limited to 'become_yukarin/loss.py')
-rw-r--r--become_yukarin/loss.py32
1 files changed, 0 insertions, 32 deletions
diff --git a/become_yukarin/loss.py b/become_yukarin/loss.py
deleted file mode 100644
index b2b03fc..0000000
--- a/become_yukarin/loss.py
+++ /dev/null
@@ -1,32 +0,0 @@
-import chainer
-from chainer import reporter
-
-from .config import LossConfig
-from .model import Aligner
-from .model import Predictor
-
-
-class Loss(chainer.link.Chain):
- def __init__(self, config: LossConfig, predictor: Predictor, aligner: Aligner = None):
- super().__init__()
- self.config = config
-
- with self.init_scope():
- self.predictor = predictor
- self.aligner = aligner
-
- def __call__(self, input, target, mask):
- input = chainer.as_variable(input)
- target = chainer.as_variable(target)
- mask = chainer.as_variable(mask)
-
- h = input
- if self.aligner is not None:
- h = self.aligner(h)
- y = self.predictor(h)
-
- loss = chainer.functions.sum(chainer.functions.absolute_error(y, target) * mask)
- loss = loss / chainer.functions.sum(mask)
- reporter.report({'loss': loss}, self)
-
- return loss * self.config.l1