From 79f357a45168a7dc5166a2fb9ff48515cd5dd56c Mon Sep 17 00:00:00 2001 From: Virginia Fernandez Date: Fri, 9 May 2025 15:10:27 +0100 Subject: [PATCH 1/5] Fix AutoencoderKL docstrings. --- monai/networks/nets/autoencoderkl.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/monai/networks/nets/autoencoderkl.py b/monai/networks/nets/autoencoderkl.py index af191e748b..f9cec5800e 100644 --- a/monai/networks/nets/autoencoderkl.py +++ b/monai/networks/nets/autoencoderkl.py @@ -153,9 +153,9 @@ class Encoder(nn.Module): channels: sequence of block output channels. out_channels: number of channels in the bottom layer (latent space) of the autoencoder. num_res_blocks: number of residual blocks (see _ResBlock) per level. - norm_num_groups: number of groups for the GroupNorm layers, num_channels must be divisible by this number. + norm_num_groups: number of groups for the GroupNorm layers, channels must be divisible by this number. norm_eps: epsilon for the normalization. - attention_levels: indicate which level from num_channels contain an attention block. + attention_levels: indicate which level from channels contain an attention block. with_nonlocal_attn: if True use non-local attention block. include_fc: whether to include the final linear layer. Default to True. use_combined_linear: whether to use a single linear layer for qkv projection, default to False. @@ -299,9 +299,9 @@ class Decoder(nn.Module): in_channels: number of channels in the bottom layer (latent space) of the autoencoder. out_channels: number of output channels. num_res_blocks: number of residual blocks (see _ResBlock) per level. - norm_num_groups: number of groups for the GroupNorm layers, num_channels must be divisible by this number. + norm_num_groups: number of groups for the GroupNorm layers, channels must be divisible by this number. norm_eps: epsilon for the normalization. - attention_levels: indicate which level from num_channels contain an attention block. + attention_levels: indicate which level from channels contain an attention block. with_nonlocal_attn: if True use non-local attention block. use_convtranspose: if True, use ConvTranspose to upsample feature maps in decoder. include_fc: whether to include the final linear layer. Default to True. @@ -483,7 +483,7 @@ class AutoencoderKL(nn.Module): channels: number of output channels for each block. attention_levels: sequence of levels to add attention. latent_channels: latent embedding dimension. - norm_num_groups: number of groups for the GroupNorm layers, num_channels must be divisible by this number. + norm_num_groups: number of groups for the GroupNorm layers, channels must be divisible by this number. norm_eps: epsilon for the normalization. with_encoder_nonlocal_attn: if True use non-local attention block in the encoder. with_decoder_nonlocal_attn: if True use non-local attention block in the decoder. @@ -518,10 +518,10 @@ def __init__( # All number of channels should be multiple of num_groups if any((out_channel % norm_num_groups) != 0 for out_channel in channels): - raise ValueError("AutoencoderKL expects all num_channels being multiple of norm_num_groups") + raise ValueError("AutoencoderKL expects all channels being multiple of norm_num_groups") if len(channels) != len(attention_levels): - raise ValueError("AutoencoderKL expects num_channels being same size of attention_levels") + raise ValueError("AutoencoderKL expects channels being same size of attention_levels") if isinstance(num_res_blocks, int): num_res_blocks = ensure_tuple_rep(num_res_blocks, len(channels)) @@ -529,7 +529,7 @@ def __init__( if len(num_res_blocks) != len(channels): raise ValueError( "`num_res_blocks` should be a single integer or a tuple of integers with the same length as " - "`num_channels`." + "`channels`." ) self.encoder: nn.Module = Encoder( From 35c2edfc542843dc7c6f685cf093437264d5b971 Mon Sep 17 00:00:00 2001 From: Virginia Fernandez Date: Fri, 9 May 2025 15:15:45 +0100 Subject: [PATCH 2/5] Sign off. Signed-off-by: Virginia Fernandez --- monai/networks/nets/autoencoderkl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monai/networks/nets/autoencoderkl.py b/monai/networks/nets/autoencoderkl.py index f9cec5800e..385e90450d 100644 --- a/monai/networks/nets/autoencoderkl.py +++ b/monai/networks/nets/autoencoderkl.py @@ -619,7 +619,7 @@ def sampling(self, z_mu: torch.Tensor, z_sigma: torch.Tensor) -> torch.Tensor: Args: z_mu: Bx[Z_CHANNELS]x[LATENT SPACE SIZE] mean vector obtained by the encoder when you encode an image - z_sigma: Bx[Z_CHANNELS]x[LATENT SPACE SIZE] variance vector obtained by the encoder when you encode an image + z_sigma: Bx[Z_CHANNELS]x[LATENT SPACE SIZE] variance vector obtained by the encoder when you encode an image Returns: sample of shape Bx[Z_CHANNELS]x[LATENT SPACE SIZE] From f60c087a53cfcdb73ddd2d87a940c94cb641629d Mon Sep 17 00:00:00 2001 From: Virginia Fernandez Date: Fri, 9 May 2025 15:17:14 +0100 Subject: [PATCH 3/5] Remove empty space Signed-off-by: Virginia Fernandez --- monai/networks/nets/autoencoderkl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monai/networks/nets/autoencoderkl.py b/monai/networks/nets/autoencoderkl.py index 385e90450d..f9cec5800e 100644 --- a/monai/networks/nets/autoencoderkl.py +++ b/monai/networks/nets/autoencoderkl.py @@ -619,7 +619,7 @@ def sampling(self, z_mu: torch.Tensor, z_sigma: torch.Tensor) -> torch.Tensor: Args: z_mu: Bx[Z_CHANNELS]x[LATENT SPACE SIZE] mean vector obtained by the encoder when you encode an image - z_sigma: Bx[Z_CHANNELS]x[LATENT SPACE SIZE] variance vector obtained by the encoder when you encode an image + z_sigma: Bx[Z_CHANNELS]x[LATENT SPACE SIZE] variance vector obtained by the encoder when you encode an image Returns: sample of shape Bx[Z_CHANNELS]x[LATENT SPACE SIZE] From 0381eea4c8b628db5f11f434d6d8eec03e486e67 Mon Sep 17 00:00:00 2001 From: Virginia Fernandez Date: Fri, 9 May 2025 15:36:34 +0100 Subject: [PATCH 4/5] DCO Remediation Commit for Virginia Fernandez \nI, Virginia Fernandez , hereby add my Signed-off-by to this commit: 79f357a45168a7dc5166a2fb9ff48515cd5dd56c\nSigned-off-by: Virginia Fernandez Signed-off-by: Virginia Fernandez --- monai/networks/nets/autoencoderkl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monai/networks/nets/autoencoderkl.py b/monai/networks/nets/autoencoderkl.py index f9cec5800e..32b5b3bf81 100644 --- a/monai/networks/nets/autoencoderkl.py +++ b/monai/networks/nets/autoencoderkl.py @@ -614,7 +614,7 @@ def encode(self, x: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]: def sampling(self, z_mu: torch.Tensor, z_sigma: torch.Tensor) -> torch.Tensor: """ From the mean and sigma representations resulting of encoding an image through the latent space, - obtains a noise sample resulting from sampling gaussian noise, multiplying by the variance (sigma) and + obtains a noise sample resulting from sampling gaussian noise, multiplying by the variance (sigma) and adding the mean. Args: From 0ae0a685be0627d7896bfd3791d0727c56b578b8 Mon Sep 17 00:00:00 2001 From: Virginia Fernandez Date: Fri, 9 May 2025 15:36:52 +0100 Subject: [PATCH 5/5] Remove empty space Signed-off-by: Virginia Fernandez --- monai/networks/nets/autoencoderkl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monai/networks/nets/autoencoderkl.py b/monai/networks/nets/autoencoderkl.py index 32b5b3bf81..f9cec5800e 100644 --- a/monai/networks/nets/autoencoderkl.py +++ b/monai/networks/nets/autoencoderkl.py @@ -614,7 +614,7 @@ def encode(self, x: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]: def sampling(self, z_mu: torch.Tensor, z_sigma: torch.Tensor) -> torch.Tensor: """ From the mean and sigma representations resulting of encoding an image through the latent space, - obtains a noise sample resulting from sampling gaussian noise, multiplying by the variance (sigma) and + obtains a noise sample resulting from sampling gaussian noise, multiplying by the variance (sigma) and adding the mean. Args: