Skip to content

Commit

Permalink
Updates docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
marksgraham committed Jul 19, 2023
1 parent 79a3784 commit 89c4e83
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
15 changes: 15 additions & 0 deletions docs/source/losses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,21 @@ Reconstruction Losses
.. autoclass:: monai.losses.ssim_loss.SSIMLoss
:members:

`PatchAdversarialLoss`
~~~~~~~~~~~~~~~~~~~~~~
.. autoclass:: PatchAdversarialLoss
:members:

`PerceptualLoss`
~~~~~~~~~~~~~~~~~
.. autoclass:: PerceptualLoss
:members:

`JukeboxLoss`
~~~~~~~~~~~~~~
.. autoclass:: JukeboxLoss
:members:


Loss Wrappers
-------------
Expand Down
26 changes: 14 additions & 12 deletions monai/losses/adversarial_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ class PatchAdversarialLoss(_Loss):
mustn't be passed to a final activation layer. That is taken care of internally within the loss.
Args:
reduction: {``"none"``, ``"mean"``, ``"sum"``} Specifies the reduction to apply to the output.
Defaults to ``"mean"``.
- ``"none"``: no reduction will be applied.
- ``"mean"``: the sum of the output will be divided by the number of elements in the output.
- ``"sum"``: the output will be summed.
reduction: {``"none"``, ``"mean"``, ``"sum"``}
Specifies the reduction to apply to the output. Defaults to ``"mean"``.
- ``"none"``: no reduction will be applied.
- ``"mean"``: the sum of the output will be divided by the number of elements in the output.
- ``"sum"``: the output will be summed.
criterion: which criterion (hinge, least_squares or bce) you want to use on the discriminators outputs.
Depending on the criterion, a different activation layer will be used. Make sure you don't run the outputs
through an activation layer prior to calling the loss.
Depending on the criterion, a different activation layer will be used. Make sure you don't run the outputs
through an activation layer prior to calling the loss.
no_activation_leastsq: if True, the activation layer in the case of least-squares is removed.
"""

Expand Down Expand Up @@ -112,14 +114,14 @@ def forward(
"""
Args:
input: output of Multi-Scale Patch Discriminator or Patch Discriminator; being a list of
tensors or a tensor; they shouldn't have gone through an activation layer.
input: output of Multi-Scale Patch Discriminator or Patch Discriminator; being a list of tensors
or a tensor; they shouldn't have gone through an activation layer.
target_is_real: whereas the input corresponds to discriminator output for real or fake images
for_discriminator: whereas this is being calculated for discriminator or generator loss. In the last
case, target_is_real is set to True, as the generator wants the input to be dimmed as real.
case, target_is_real is set to True, as the generator wants the input to be dimmed as real.
Returns: if reduction is None, returns a list with the loss tensors of each discriminator if multi-scale
discriminator is active, or the loss tensor if there is just one discriminator. Otherwise, it returns the
summed or mean loss over the tensor and discriminator/s.
discriminator is active, or the loss tensor if there is just one discriminator. Otherwise, it returns the
summed or mean loss over the tensor and discriminator/s.
"""

Expand Down
2 changes: 1 addition & 1 deletion monai/losses/spectral_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class JukeboxLoss(_Loss):
Calculate spectral component based on the magnitude of Fast Fourier Transform (FFT).
Based on:
Dhariwal, et al. 'Jukebox: A generative model for music.'https://arxiv.org/abs/2005.00341
Dhariwal, et al. 'Jukebox: A generative model for music.' https://arxiv.org/abs/2005.00341
Args:
spatial_dims: number of spatial dimensions.
Expand Down

0 comments on commit 89c4e83

Please sign in to comment.