[Fix] Fix optional issues in docstring (#138)
* fix optional issue in docstring * revised according to comments * add optionalpull/139/head
parent
6916f33d56
commit
63f38988eb
|
@ -50,7 +50,7 @@ class DistEvalHook(EvalHook):
|
|||
Args:
|
||||
dataloader (DataLoader): A PyTorch dataloader.
|
||||
interval (int): Evaluation interval (by epochs). Default: 1.
|
||||
tmpdir (str | None): Temporary directory to save the results of all
|
||||
tmpdir (str, optional): Temporary directory to save the results of all
|
||||
processes. Default: None.
|
||||
gpu_collect (bool): Whether to use gpu or cpu to collect results.
|
||||
Default: False.
|
||||
|
|
|
@ -306,7 +306,7 @@ class RandomFlip(object):
|
|||
|
||||
Args:
|
||||
flip_prob (float): probability of the image being flipped. Default: 0.5
|
||||
direction (str, optional): The flipping direction. Options are
|
||||
direction (str): The flipping direction. Options are
|
||||
'horizontal' and 'vertical'. Default: 'horizontal'.
|
||||
"""
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ class InvertedResidual(nn.Module):
|
|||
stride (int): Stride of the middle (first) 3x3 convolution.
|
||||
expand_ratio (int): adjusts number of channels of the hidden layer
|
||||
in InvertedResidual by this amount.
|
||||
conv_cfg (dict): Config dict for convolution layer.
|
||||
conv_cfg (dict, optional): Config dict for convolution layer.
|
||||
Default: None, which means using conv2d.
|
||||
norm_cfg (dict): Config dict for normalization layer.
|
||||
Default: dict(type='BN').
|
||||
|
@ -108,7 +108,7 @@ class MobileNetV2(BaseBackbone):
|
|||
Default: (7, ).
|
||||
frozen_stages (int): Stages to be frozen (all param fixed).
|
||||
Default: -1, which means not freezing any parameters.
|
||||
conv_cfg (dict): Config dict for convolution layer.
|
||||
conv_cfg (dict, optional): Config dict for convolution layer.
|
||||
Default: None, which means using conv2d.
|
||||
norm_cfg (dict): Config dict for normalization layer.
|
||||
Default: dict(type='BN').
|
||||
|
|
|
@ -17,7 +17,7 @@ class MobileNetv3(BaseBackbone):
|
|||
Args:
|
||||
arch (str): Architechture of mobilnetv3, from {small, big}.
|
||||
Default: small.
|
||||
conv_cfg (dict): Config dict for convolution layer.
|
||||
conv_cfg (dict, optional): Config dict for convolution layer.
|
||||
Default: None, which means using conv2d.
|
||||
norm_cfg (dict): Config dict for normalization layer.
|
||||
Default: dict(type='BN').
|
||||
|
|
|
@ -215,7 +215,7 @@ class RegNet(ResNet):
|
|||
width_slope ([float]): Slope of the quantized linear function
|
||||
width_parameter ([int]): Parameter used to quantize the width.
|
||||
depth ([int]): Depth of the backbone.
|
||||
divisor (int, optional): The divisor of channels. Defaults to 8.
|
||||
divisor (int): The divisor of channels. Defaults to 8.
|
||||
|
||||
Returns:
|
||||
list, int: return a list of widths of each stage and the number of
|
||||
|
|
|
@ -47,9 +47,10 @@ class SplitAttentionConv2d(nn.Module):
|
|||
radix (int): Radix of SpltAtConv2d. Default: 2
|
||||
reduction_factor (int): Reduction factor of SplitAttentionConv2d.
|
||||
Default: 4.
|
||||
conv_cfg (dict): Config dict for convolution layer. Default: None,
|
||||
which means using conv2d.
|
||||
norm_cfg (dict): Config dict for normalization layer. Default: None.
|
||||
conv_cfg (dict, optional): Config dict for convolution layer.
|
||||
Default: None, which means using conv2d.
|
||||
norm_cfg (dict, optional): Config dict for normalization layer.
|
||||
Default: None.
|
||||
"""
|
||||
|
||||
def __init__(self,
|
||||
|
@ -145,13 +146,13 @@ class Bottleneck(_Bottleneck):
|
|||
Bottleneck. Default: True.
|
||||
stride (int): stride of the block. Default: 1
|
||||
dilation (int): dilation of convolution. Default: 1
|
||||
downsample (nn.Module): downsample operation on identity branch.
|
||||
Default: None
|
||||
downsample (nn.Module, optional): downsample operation on identity
|
||||
branch. Default: None
|
||||
style (str): `pytorch` or `caffe`. If set to "pytorch", the stride-two
|
||||
layer is the 3x3 conv layer, otherwise the stride-two layer is
|
||||
the first 1x1 conv layer.
|
||||
conv_cfg (dict): dictionary to construct and config conv layer.
|
||||
Default: None
|
||||
conv_cfg (dict, optional): dictionary to construct and config conv
|
||||
layer. Default: None
|
||||
norm_cfg (dict): dictionary to construct and config norm layer.
|
||||
Default: dict(type='BN')
|
||||
with_cp (bool): Use checkpoint or not. Using checkpoint will save some
|
||||
|
|
|
@ -19,14 +19,14 @@ class BasicBlock(nn.Module):
|
|||
reserved argument in BasicBlock and should always be 1. Default: 1.
|
||||
stride (int): stride of the block. Default: 1
|
||||
dilation (int): dilation of convolution. Default: 1
|
||||
downsample (nn.Module): downsample operation on identity branch.
|
||||
Default: None.
|
||||
downsample (nn.Module, optional): downsample operation on identity
|
||||
branch. Default: None.
|
||||
style (str): `pytorch` or `caffe`. It is unused and reserved for
|
||||
unified API with Bottleneck.
|
||||
with_cp (bool): Use checkpoint or not. Using checkpoint will save some
|
||||
memory while slowing down the training speed.
|
||||
conv_cfg (dict): dictionary to construct and config conv layer.
|
||||
Default: None
|
||||
conv_cfg (dict, optional): dictionary to construct and config conv
|
||||
layer. Default: None
|
||||
norm_cfg (dict): dictionary to construct and config norm layer.
|
||||
Default: dict(type='BN')
|
||||
"""
|
||||
|
@ -130,15 +130,15 @@ class Bottleneck(nn.Module):
|
|||
``mid_channels`` is the input/output channels of conv2. Default: 4.
|
||||
stride (int): stride of the block. Default: 1
|
||||
dilation (int): dilation of convolution. Default: 1
|
||||
downsample (nn.Module): downsample operation on identity branch.
|
||||
Default: None.
|
||||
downsample (nn.Module, optional): downsample operation on identity
|
||||
branch. Default: None.
|
||||
style (str): ``"pytorch"`` or ``"caffe"``. If set to "pytorch", the
|
||||
stride-two layer is the 3x3 conv layer, otherwise the stride-two
|
||||
layer is the first 1x1 conv layer. Default: "pytorch".
|
||||
with_cp (bool): Use checkpoint or not. Using checkpoint will save some
|
||||
memory while slowing down the training speed.
|
||||
conv_cfg (dict): dictionary to construct and config conv layer.
|
||||
Default: None
|
||||
conv_cfg (dict, optional): dictionary to construct and config conv
|
||||
layer. Default: None
|
||||
norm_cfg (dict): dictionary to construct and config norm layer.
|
||||
Default: dict(type='BN')
|
||||
"""
|
||||
|
@ -309,8 +309,8 @@ class ResLayer(nn.Sequential):
|
|||
stride (int): stride of the first block. Default: 1.
|
||||
avg_down (bool): Use AvgPool instead of stride conv when
|
||||
downsampling in the bottleneck. Default: False
|
||||
conv_cfg (dict): dictionary to construct and config conv layer.
|
||||
Default: None
|
||||
conv_cfg (dict, optional): dictionary to construct and config conv
|
||||
layer. Default: None
|
||||
norm_cfg (dict): dictionary to construct and config norm layer.
|
||||
Default: dict(type='BN')
|
||||
"""
|
||||
|
|
|
@ -17,13 +17,13 @@ class Bottleneck(_Bottleneck):
|
|||
``groups=32, width_per_group=8``.
|
||||
stride (int): stride of the block. Default: 1
|
||||
dilation (int): dilation of convolution. Default: 1
|
||||
downsample (nn.Module): downsample operation on identity branch.
|
||||
Default: None
|
||||
downsample (nn.Module, optional): downsample operation on identity
|
||||
branch. Default: None
|
||||
style (str): `pytorch` or `caffe`. If set to "pytorch", the stride-two
|
||||
layer is the 3x3 conv layer, otherwise the stride-two layer is
|
||||
the first 1x1 conv layer.
|
||||
conv_cfg (dict): dictionary to construct and config conv layer.
|
||||
Default: None
|
||||
conv_cfg (dict, optional): dictionary to construct and config conv
|
||||
layer. Default: None
|
||||
norm_cfg (dict): dictionary to construct and config norm layer.
|
||||
Default: dict(type='BN')
|
||||
with_cp (bool): Use checkpoint or not. Using checkpoint will save some
|
||||
|
|
|
@ -19,14 +19,14 @@ class SEBottleneck(_SEBottleneck):
|
|||
``groups=32, width_per_group=8``.
|
||||
stride (int): stride of the block. Default: 1
|
||||
dilation (int): dilation of convolution. Default: 1
|
||||
downsample (nn.Module): downsample operation on identity branch.
|
||||
Default: None
|
||||
downsample (nn.Module, optional): downsample operation on identity
|
||||
branch. Default: None
|
||||
se_ratio (int): Squeeze ratio in SELayer. Default: 16
|
||||
style (str): `pytorch` or `caffe`. If set to "pytorch", the stride-two
|
||||
layer is the 3x3 conv layer, otherwise the stride-two layer is
|
||||
the first 1x1 conv layer.
|
||||
conv_cfg (dict): dictionary to construct and config conv layer.
|
||||
Default: None
|
||||
conv_cfg (dict, optional): dictionary to construct and config conv
|
||||
layer. Default: None
|
||||
norm_cfg (dict): dictionary to construct and config norm layer.
|
||||
Default: dict(type='BN')
|
||||
with_cp (bool): Use checkpoint or not. Using checkpoint will save some
|
||||
|
|
|
@ -22,20 +22,20 @@ class ShuffleUnit(nn.Module):
|
|||
Args:
|
||||
in_channels (int): The input channels of the ShuffleUnit.
|
||||
out_channels (int): The output channels of the ShuffleUnit.
|
||||
groups (int, optional): The number of groups to be used in grouped 1x1
|
||||
groups (int): The number of groups to be used in grouped 1x1
|
||||
convolutions in each ShuffleUnit. Default: 3
|
||||
first_block (bool, optional): Whether it is the first ShuffleUnit of a
|
||||
first_block (bool): Whether it is the first ShuffleUnit of a
|
||||
sequential ShuffleUnits. Default: False, which means not using the
|
||||
grouped 1x1 convolution.
|
||||
combine (str, optional): The ways to combine the input and output
|
||||
combine (str): The ways to combine the input and output
|
||||
branches. Default: 'add'.
|
||||
conv_cfg (dict): Config dict for convolution layer. Default: None,
|
||||
which means using conv2d.
|
||||
conv_cfg (dict, optional): Config dict for convolution layer.
|
||||
Default: None, which means using conv2d.
|
||||
norm_cfg (dict): Config dict for normalization layer.
|
||||
Default: dict(type='BN').
|
||||
act_cfg (dict): Config dict for activation layer.
|
||||
Default: dict(type='ReLU').
|
||||
with_cp (bool, optional): Use checkpoint or not. Using checkpoint
|
||||
with_cp (bool): Use checkpoint or not. Using checkpoint
|
||||
will save some memory while slowing down the training speed.
|
||||
Default: False.
|
||||
|
||||
|
@ -154,16 +154,16 @@ class ShuffleNetV1(BaseBackbone):
|
|||
"""ShuffleNetV1 backbone.
|
||||
|
||||
Args:
|
||||
groups (int, optional): The number of groups to be used in grouped 1x1
|
||||
groups (int): The number of groups to be used in grouped 1x1
|
||||
convolutions in each ShuffleUnit. Default: 3.
|
||||
widen_factor (float, optional): Width multiplier - adjusts the number
|
||||
widen_factor (float): Width multiplier - adjusts the number
|
||||
of channels in each layer by this amount. Default: 1.0.
|
||||
out_indices (Sequence[int]): Output from which stages.
|
||||
Default: (2, )
|
||||
frozen_stages (int): Stages to be frozen (all param fixed).
|
||||
Default: -1, which means not freezing any parameters.
|
||||
conv_cfg (dict): Config dict for convolution layer. Default: None,
|
||||
which means using conv2d.
|
||||
conv_cfg (dict, optional): Config dict for convolution layer.
|
||||
Default: None, which means using conv2d.
|
||||
norm_cfg (dict): Config dict for normalization layer.
|
||||
Default: dict(type='BN').
|
||||
act_cfg (dict): Config dict for activation layer.
|
||||
|
@ -276,7 +276,7 @@ class ShuffleNetV1(BaseBackbone):
|
|||
Args:
|
||||
out_channels (int): out_channels of the block.
|
||||
num_blocks (int): Number of blocks.
|
||||
first_block (bool, optional): Whether is the first ShuffleUnit of a
|
||||
first_block (bool): Whether is the first ShuffleUnit of a
|
||||
sequential ShuffleUnits. Default: False, which means not using
|
||||
the grouped 1x1 convolution.
|
||||
"""
|
||||
|
|
|
@ -19,7 +19,7 @@ class InvertedResidual(nn.Module):
|
|||
in_channels (int): The input channels of the block.
|
||||
out_channels (int): The output channels of the block.
|
||||
stride (int): Stride of the 3x3 convolution layer. Default: 1
|
||||
conv_cfg (dict): Config dict for convolution layer.
|
||||
conv_cfg (dict, optional): Config dict for convolution layer.
|
||||
Default: None, which means using conv2d.
|
||||
norm_cfg (dict): Config dict for normalization layer.
|
||||
Default: dict(type='BN').
|
||||
|
@ -141,7 +141,7 @@ class ShuffleNetV2(BaseBackbone):
|
|||
Default: (0, 1, 2, 3).
|
||||
frozen_stages (int): Stages to be frozen (all param fixed).
|
||||
Default: -1, which means not freezing any parameters.
|
||||
conv_cfg (dict): Config dict for convolution layer.
|
||||
conv_cfg (dict, optional): Config dict for convolution layer.
|
||||
Default: None, which means using conv2d.
|
||||
norm_cfg (dict): Config dict for normalization layer.
|
||||
Default: dict(type='BN').
|
||||
|
|
|
@ -44,14 +44,14 @@ class VGG(BaseBackbone):
|
|||
num_classes (int): number of classes for classification.
|
||||
num_stages (int): VGG stages, normally 5.
|
||||
dilations (Sequence[int]): Dilation of each stage.
|
||||
out_indices (Sequence[int]): Output from which stages. If only one
|
||||
stage is specified, a single tensor (feature map) is returned,
|
||||
otherwise multiple stages are specified, a tuple of tensors will
|
||||
be returned. When it is None, the default behavior depends on
|
||||
whether num_classes is specified. If num_classes <= 0, the default
|
||||
value is (4, ), outputing the last feature map before classifier.
|
||||
If num_classes > 0, the default value is (5, ), outputing the
|
||||
classification score. Default: None.
|
||||
out_indices (Sequence[int], optional): Output from which stages.
|
||||
If only one stage is specified, a single tensor (feature map) is
|
||||
returned, otherwise multiple stages are specified, a tuple of
|
||||
tensors will be returned. When it is None, the default behavior
|
||||
depends on whether num_classes is specified. If num_classes <= 0,
|
||||
the default value is (4, ), outputing the last feature map before
|
||||
classifier. If num_classes > 0, the default value is (5, ),
|
||||
outputing the classification score. Default: None.
|
||||
frozen_stages (int): Stages to be frozen (all param fixed). -1 means
|
||||
not freezing any parameters.
|
||||
norm_eval (bool): Whether to set norm layers to eval mode, namely,
|
||||
|
|
|
@ -36,7 +36,7 @@ def accuracy(pred, target, topk=1):
|
|||
Args:
|
||||
pred (torch.Tensor | np.array): The model prediction.
|
||||
target (torch.Tensor | np.array): The target of each prediction
|
||||
topk (int | tuple[int], optional): If the predictions in ``topk``
|
||||
topk (int | tuple[int]): If the predictions in ``topk``
|
||||
matches the target, the predictions will be regarded as
|
||||
correct ones. Defaults to 1.
|
||||
|
||||
|
@ -71,7 +71,7 @@ class Accuracy(nn.Module):
|
|||
"""Module to calculate the accuracy
|
||||
|
||||
Args:
|
||||
topk (tuple, optional): The criterion used to calculate the
|
||||
topk (tuple): The criterion used to calculate the
|
||||
accuracy. Defaults to (1,).
|
||||
"""
|
||||
super().__init__()
|
||||
|
|
|
@ -24,12 +24,11 @@ def asymmetric_loss(pred,
|
|||
shape (N, *).
|
||||
weight (torch.Tensor, optional): Sample-wise loss weight with shape
|
||||
(N, ). Dafaults to None.
|
||||
gamma_pos (float, optional): positive focusing parameter.
|
||||
Defaults to 0.0.
|
||||
gamma_neg (float, optional): Negative focusing parameter. We usually
|
||||
set gamma_neg > gamma_pos. Defaults to 4.0.
|
||||
gamma_pos (float): positive focusing parameter. Defaults to 0.0.
|
||||
gamma_neg (float): Negative focusing parameter. We usually set
|
||||
gamma_neg > gamma_pos. Defaults to 4.0.
|
||||
clip (float, optional): Probability margin. Defaults to 0.05.
|
||||
reduction (str, optional): The method used to reduce the loss.
|
||||
reduction (str): The method used to reduce the loss.
|
||||
Options are "none", "mean" and "sum". If reduction is 'none' , loss
|
||||
is same shape as pred and label. Defaults to 'mean'.
|
||||
avg_factor (int, optional): Average factor that is used to average
|
||||
|
@ -67,14 +66,14 @@ class AsymmetricLoss(nn.Module):
|
|||
"""asymmetric loss
|
||||
|
||||
Args:
|
||||
gamma_pos (float, optional): positive focusing parameter.
|
||||
gamma_pos (float): positive focusing parameter.
|
||||
Defaults to 0.0.
|
||||
gamma_neg (float, optional): Negative focusing parameter. We
|
||||
gamma_neg (float): Negative focusing parameter. We
|
||||
usually set gamma_neg > gamma_pos. Defaults to 4.0.
|
||||
clip (float, optional): Probability margin. Defaults to 0.05.
|
||||
reduction (str, optional): The method used to reduce the loss into
|
||||
reduction (str): The method used to reduce the loss into
|
||||
a scalar.
|
||||
loss_weight (float, optional): Weight of loss. Defaults to 1.0.
|
||||
loss_weight (float): Weight of loss. Defaults to 1.0.
|
||||
"""
|
||||
|
||||
def __init__(self,
|
||||
|
|
|
@ -13,10 +13,10 @@ def cross_entropy(pred, label, weight=None, reduction='mean', avg_factor=None):
|
|||
of classes.
|
||||
label (torch.Tensor): The learning label of the prediction.
|
||||
weight (torch.Tensor, optional): Sample-wise loss weight.
|
||||
reduction (str, optional): The method used to reduce the loss.
|
||||
reduction (str): The method used to reduce the loss.
|
||||
avg_factor (int, optional): Average factor that is used to average
|
||||
the loss. Defaults to None.
|
||||
class_weight (list[float], optional): The weight for each class.
|
||||
|
||||
Returns:
|
||||
torch.Tensor: The calculated loss
|
||||
"""
|
||||
|
@ -44,7 +44,7 @@ def binary_cross_entropy(pred,
|
|||
label (torch.Tensor): The learning label with shape (N, *).
|
||||
weight (torch.Tensor, optional): Element-wise weight of loss with shape
|
||||
(N, ). Defaults to None.
|
||||
reduction (str, optional): The method used to reduce the loss.
|
||||
reduction (str): The method used to reduce the loss.
|
||||
Options are "none", "mean" and "sum". If reduction is 'none' , loss
|
||||
is same shape as pred and label. Defaults to 'mean'.
|
||||
avg_factor (int, optional): Average factor that is used to average
|
||||
|
@ -73,12 +73,11 @@ class CrossEntropyLoss(nn.Module):
|
|||
"""Cross entropy loss
|
||||
|
||||
Args:
|
||||
use_sigmoid (bool, optional): Whether the prediction uses sigmoid
|
||||
use_sigmoid (bool): Whether the prediction uses sigmoid
|
||||
of softmax. Defaults to False.
|
||||
reduction (str, optional): The method used to reduce the loss.
|
||||
Options are "none", "mean" and "sum". Defaults to 'mean'.
|
||||
loss_weight (float, optional): Weight of the loss.
|
||||
Defaults to 1.0.
|
||||
reduction (str): The method used to reduce the loss.
|
||||
Options are "none", "mean" and "sum". Defaults to 'mean'.
|
||||
loss_weight (float): Weight of the loss. Defaults to 1.0.
|
||||
"""
|
||||
|
||||
def __init__(self, use_sigmoid=False, reduction='mean', loss_weight=1.0):
|
||||
|
|
|
@ -20,13 +20,12 @@ def sigmoid_focal_loss(pred,
|
|||
shape (N, *).
|
||||
weight (torch.Tensor, optional): Sample-wise loss weight with shape
|
||||
(N, ). Dafaults to None.
|
||||
gamma (float, optional): The gamma for calculating the modulating
|
||||
factor. Defaults to 2.0.
|
||||
alpha (float, optional): A balanced form for Focal Loss.
|
||||
Defaults to 0.25.
|
||||
reduction (str, optional): The method used to reduce the loss.
|
||||
Options are "none", "mean" and "sum". If reduction is 'none' , loss
|
||||
is same shape as pred and label. Defaults to 'mean'.
|
||||
gamma (float): The gamma for calculating the modulating factor.
|
||||
Defaults to 2.0.
|
||||
alpha (float): A balanced form for Focal Loss. Defaults to 0.25.
|
||||
reduction (str): The method used to reduce the loss.
|
||||
Options are "none", "mean" and "sum". If reduction is 'none' ,
|
||||
loss is same shape as pred and label. Defaults to 'mean'.
|
||||
avg_factor (int, optional): Average factor that is used to average
|
||||
the loss. Defaults to None.
|
||||
|
||||
|
@ -56,13 +55,13 @@ class FocalLoss(nn.Module):
|
|||
"""Focal loss
|
||||
|
||||
Args:
|
||||
gamma (float, optional): Focusing parameter in focal loss.
|
||||
gamma (float): Focusing parameter in focal loss.
|
||||
Defaults to 2.0.
|
||||
alpha (float, optional): The parameter in balanced form of focal
|
||||
alpha (float): The parameter in balanced form of focal
|
||||
loss. Defaults to 0.25.
|
||||
reduction (str, optional): The method used to reduce the loss into
|
||||
reduction (str): The method used to reduce the loss into
|
||||
a scalar. Options are "none" and "mean". Defaults to 'mean'.
|
||||
loss_weight (float, optional): Weight of loss. Defaults to 1.0.
|
||||
loss_weight (float): Weight of loss. Defaults to 1.0.
|
||||
"""
|
||||
|
||||
def __init__(self,
|
||||
|
@ -95,7 +94,7 @@ class FocalLoss(nn.Module):
|
|||
the loss. Defaults to None.
|
||||
reduction_override (str, optional): The method used to reduce the
|
||||
loss into a scalar. Options are "none", "mean" and "sum".
|
||||
Defaults to 'mean'.
|
||||
Defaults to None.
|
||||
|
||||
Returns:
|
||||
torch.Tensor: Loss.
|
||||
|
|
|
@ -9,7 +9,7 @@ def make_divisible(value, divisor, min_value=None, min_ratio=0.9):
|
|||
divisor (int): The divisor to fully divide the channel number.
|
||||
min_value (int, optional): The minimum value of the output channel.
|
||||
Default: None, means that the minimum value equal to the divisor.
|
||||
min_ratio (float, optional): The minimum ratio of the rounded channel
|
||||
min_ratio (float): The minimum ratio of the rounded channel
|
||||
number to the original channel number. Default: 0.9.
|
||||
Returns:
|
||||
int: The modified output channel number
|
||||
|
|
Loading…
Reference in New Issue