From 4769958e9c774bf280f7dbddc963de0e1bdc233b Mon Sep 17 00:00:00 2001 From: wony617 <49024958+Jwaminju@users.noreply.github.com> Date: Sun, 6 Oct 2024 03:48:51 +0900 Subject: [PATCH 1/3] [docs] refactoring docstrings in community/hd_painter.py --- examples/community/hd_painter.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/examples/community/hd_painter.py b/examples/community/hd_painter.py index df41be9ef7b1..3a32f151bf85 100644 --- a/examples/community/hd_painter.py +++ b/examples/community/hd_painter.py @@ -898,13 +898,16 @@ class GaussianSmoothing(nn.Module): Apply gaussian smoothing on a 1d, 2d or 3d tensor. Filtering is performed seperately for each channel in the input using a depthwise convolution. - Arguments: - channels (int, sequence): Number of channels of the input tensors. Output will - have this number of channels as well. - kernel_size (int, sequence): Size of the gaussian kernel. - sigma (float, sequence): Standard deviation of the gaussian kernel. - dim (int, optional): The number of dimensions of the data. - Default value is 2 (spatial). + + Args: + channels (`int` or `sequence`): + Number of channels of the input tensors. The output will have this number of channels as well. + kernel_size (`int` or `sequence`): + Size of the Gaussian kernel. + sigma (`float` or `sequence`): + Standard deviation of the Gaussian kernel. + dim (`int`, *optional*, defaults to `2`): + The number of dimensions of the data. Default is 2 (spatial dimensions). """ def __init__(self, channels, kernel_size, sigma, dim=2): @@ -944,10 +947,14 @@ def __init__(self, channels, kernel_size, sigma, dim=2): def forward(self, input): """ Apply gaussian filter to input. - Arguments: - input (torch.Tensor): Input to apply gaussian filter on. + + Args: + input (`torch.Tensor` of shape `(N, C, H, W)`): + Input to apply Gaussian filter on. + Returns: - filtered (torch.Tensor): Filtered output. + `torch.Tensor`: + The filtered output tensor with the same shape as the input. """ return self.conv(input, weight=self.weight.to(input.dtype), groups=self.groups, padding="same") From 597ebf343bfddb51e24f9833c651fa5d867457eb Mon Sep 17 00:00:00 2001 From: wony617 <49024958+Jwaminju@users.noreply.github.com> Date: Sun, 6 Oct 2024 12:00:54 +0900 Subject: [PATCH 2/3] Update examples/community/hd_painter.py Co-authored-by: Aryan --- examples/community/hd_painter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/community/hd_painter.py b/examples/community/hd_painter.py index 3a32f151bf85..baab70c31e97 100644 --- a/examples/community/hd_painter.py +++ b/examples/community/hd_painter.py @@ -949,8 +949,8 @@ def forward(self, input): Apply gaussian filter to input. Args: - input (`torch.Tensor` of shape `(N, C, H, W)`): - Input to apply Gaussian filter on. + input (`torch.Tensor` of shape `(N, C, H, W)`): + Input to apply Gaussian filter on. Returns: `torch.Tensor`: From bbcdbc0bd9061c73e3b56d27d66869abe9df03cf Mon Sep 17 00:00:00 2001 From: Aryan Date: Tue, 15 Oct 2024 15:09:17 +0200 Subject: [PATCH 3/3] make style --- examples/community/hd_painter.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/community/hd_painter.py b/examples/community/hd_painter.py index baab70c31e97..91ebe076104a 100644 --- a/examples/community/hd_painter.py +++ b/examples/community/hd_painter.py @@ -900,13 +900,13 @@ class GaussianSmoothing(nn.Module): in the input using a depthwise convolution. Args: - channels (`int` or `sequence`): + channels (`int` or `sequence`): Number of channels of the input tensors. The output will have this number of channels as well. - kernel_size (`int` or `sequence`): + kernel_size (`int` or `sequence`): Size of the Gaussian kernel. - sigma (`float` or `sequence`): + sigma (`float` or `sequence`): Standard deviation of the Gaussian kernel. - dim (`int`, *optional*, defaults to `2`): + dim (`int`, *optional*, defaults to `2`): The number of dimensions of the data. Default is 2 (spatial dimensions). """ @@ -953,7 +953,7 @@ def forward(self, input): Input to apply Gaussian filter on. Returns: - `torch.Tensor`: + `torch.Tensor`: The filtered output tensor with the same shape as the input. """ return self.conv(input, weight=self.weight.to(input.dtype), groups=self.groups, padding="same")