Losses¶
CycleLoss¶
-
class
CycleLoss
(loss_fn=<sphinx.ext.autodoc.importer._MockObject object>)[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObject
Computes a cyclic loss between the original and reconstructed images of each domain
Parameters: loss_fn (optional) – the actual loss function to compute a pixelwise loss (the default is :class:`torch.nn.L1Loss`()) -
forward
(target_a: <sphinx.ext.autodoc.importer._MockObject object at 0x7f897ab4f860>, target_b: <sphinx.ext.autodoc.importer._MockObject object at 0x7f897ab4f940>, rec_a: <sphinx.ext.autodoc.importer._MockObject object at 0x7f897ab4fc88>, rec_b: <sphinx.ext.autodoc.importer._MockObject object at 0x7f897ab4fcf8>)[source]¶ Calculates the actual loss
Parameters: - target_a (
torch.Tensor
) – the target image of domain A - target_b (
torch.Tensor
) – the target image of domain B - rec_a (
torch.Tensor
) – the reconstructed image of domain A - rec_b (
torch.Tensor
) – the reconstructed image of domain B
Returns: the loss value
Return type: - target_a (
-
AdversarialLoss¶
-
class
AdversarialLoss
(loss_fn=<sphinx.ext.autodoc.importer._MockObject object>)[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObject
Calculates an adversarial loss on the classification results of the fake images of both image domains (needed to update the generators)
Parameters: loss_fn (optional) – the actual loss function computing the losses (the default is :class:`torch.nn.BCELoss`()) -
forward
(fake_a_cls: <sphinx.ext.autodoc.importer._MockObject object at 0x7f897ab4fe10>, fake_b_cls: <sphinx.ext.autodoc.importer._MockObject object at 0x7f897ab4ff98>)[source]¶ Calculates the actual loss
Parameters: - fake_a_cls (
torch.Tensor
) – classification result of the fake image in domain A - fake_b_cls (
torch.Tensor
) – classification result of the fake image in domain B
Returns: the loss value
Return type: - fake_a_cls (
-
DiscriminatorLoss¶
-
class
DiscriminatorLoss
(loss_fn=<sphinx.ext.autodoc.importer._MockObject object>)[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObject
Calculates a classical discriminator loss (classification whether image is real or fake)
Parameters: loss_fn (optional) – the actual loss function computing the losses (the default is :class:`torch.nn.BCELoss`()) -
forward
(real_cl: <sphinx.ext.autodoc.importer._MockObject object at 0x7f897ab4fa20>, fake_cl: <sphinx.ext.autodoc.importer._MockObject object at 0x7f897ab4f8d0>)[source]¶ Calculates the actual loss
Parameters: - real_cl (
torch.Tensor
) – classification result of the real image - fake_cl (
torch.Tensor
) – classification result of the fake image
Returns: the loss value
Return type: - real_cl (
-