Skip to content

Commit 3bef09f

Browse files
committed
Tweak a few docstrings
1 parent 015ac30 commit 3bef09f

File tree

3 files changed

+32
-26
lines changed

3 files changed

+32
-26
lines changed

timm/data/auto_augment.py

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -584,22 +584,22 @@ def __repr__(self):
584584

585585

586586
def auto_augment_transform(config_str: str, hparams: Optional[Dict] = None):
587-
"""
588-
Create a AutoAugment transform
587+
""" Create a AutoAugment transform
589588
590589
Args:
591590
config_str: String defining configuration of auto augmentation. Consists of multiple sections separated by
592591
dashes ('-').
593592
The first section defines the AutoAugment policy (one of 'v0', 'v0r', 'original', 'originalr').
594-
595-
The remaining sections:
596-
'mstd' - float std deviation of magnitude noise applied
597-
Ex 'original-mstd0.5' results in AutoAugment with original policy, magnitude_std 0.5
598-
593+
While the remaining sections define other arguments
594+
* 'mstd' - float std deviation of magnitude noise applied
599595
hparams: Other hparams (kwargs) for the AutoAugmentation scheme
600596
601597
Returns:
602598
A PyTorch compatible Transform
599+
600+
Examples::
601+
602+
'original-mstd0.5' results in AutoAugment with original policy, magnitude_std 0.5
603603
"""
604604
config = config_str.split('-')
605605
policy_name = config[0]
@@ -764,27 +764,30 @@ def rand_augment_transform(
764764
hparams: Optional[Dict] = None,
765765
transforms: Optional[Union[str, Dict, List]] = None,
766766
):
767-
"""
768-
Create a RandAugment transform
767+
""" Create a RandAugment transform
769768
770769
Args:
771770
config_str (str): String defining configuration of random augmentation. Consists of multiple sections separated
772771
by dashes ('-'). The first section defines the specific variant of rand augment (currently only 'rand').
773-
The remaining sections, not order sepecific determine
774-
'm' - integer magnitude of rand augment
775-
'n' - integer num layers (number of transform ops selected per image)
776-
'p' - float probability of applying each layer (default 0.5)
777-
'mstd' - float std deviation of magnitude noise applied, or uniform sampling if infinity (or > 100)
778-
'mmax' - set upper bound for magnitude to something other than default of _LEVEL_DENOM (10)
779-
'inc' - integer (bool), use augmentations that increase in severity with magnitude (default: 0)
780-
't' - str name of transform set to use
781-
Ex 'rand-m9-n3-mstd0.5' results in RandAugment with magnitude 9, num_layers 3, magnitude_std 0.5
782-
'rand-mstd1-tweights' results in mag std 1.0, weighted transforms, default mag of 10 and num_layers 2
783-
772+
The remaining sections, not order specific determine
773+
* 'm' - integer magnitude of rand augment
774+
* 'n' - integer num layers (number of transform ops selected per image)
775+
* 'p' - float probability of applying each layer (default 0.5)
776+
* 'mstd' - float std deviation of magnitude noise applied, or uniform sampling if infinity (or > 100)
777+
* 'mmax' - set upper bound for magnitude to something other than default of _LEVEL_DENOM (10)
778+
* 'inc' - integer (bool), use augmentations that increase in severity with magnitude (default: 0)
779+
* 't' - str name of transform set to use
784780
hparams (dict): Other hparams (kwargs) for the RandAugmentation scheme
785781
786782
Returns:
787783
A PyTorch compatible Transform
784+
785+
Examples::
786+
787+
'rand-m9-n3-mstd0.5' results in RandAugment with magnitude 9, num_layers 3, magnitude_std 0.5
788+
789+
'rand-mstd1-tweights' results in mag std 1.0, weighted transforms, default mag of 10 and num_layers 2
790+
788791
"""
789792
magnitude = _LEVEL_DENOM # default to _LEVEL_DENOM for magnitude (currently 10)
790793
num_layers = 2 # default to 2 ops per image

timm/data/transforms_factory.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ def transforms_imagenet_train(
114114
115115
Returns:
116116
If separate==True, the transforms are returned as a tuple of 3 separate transforms
117-
for use in a mixing dataset that passes
118-
* all data through the first (primary) transform, called the 'clean' data
119-
* a portion of the data through the secondary transform
120-
* normalizes and converts the branches above with the third, final transform
117+
for use in a mixing dataset that passes
118+
* all data through the first (primary) transform, called the 'clean' data
119+
* a portion of the data through the secondary transform
120+
* normalizes and converts the branches above with the third, final transform
121121
"""
122122
train_crop_mode = train_crop_mode or 'rrc'
123123
assert train_crop_mode in {'rrc', 'rkrc', 'rkrr'}

timm/utils/model.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def extract_spp_stats(
9696
hook_fns,
9797
input_shape=[8, 3, 224, 224]):
9898
"""Extract average square channel mean and variance of activations during
99-
forward pass to plot Signal Propogation Plots (SPP).
99+
forward pass to plot Signal Propogation Plots (SPP).
100100
101101
Paper: https://arxiv.org/abs/2101.08692
102102
@@ -111,7 +111,8 @@ def extract_spp_stats(
111111
def _freeze_unfreeze(root_module, submodules=[], include_bn_running_stats=True, mode='freeze'):
112112
"""
113113
Freeze or unfreeze parameters of the specified modules and those of all their hierarchical descendants. This is
114-
done in place.
114+
done in place.
115+
115116
Args:
116117
root_module (nn.Module, optional): Root module relative to which the `submodules` are referenced.
117118
submodules (list[str]): List of modules for which the parameters will be (un)frozen. They are to be provided as
@@ -180,6 +181,7 @@ def _add_submodule(module, name, submodule):
180181
def freeze(root_module, submodules=[], include_bn_running_stats=True):
181182
"""
182183
Freeze parameters of the specified modules and those of all their hierarchical descendants. This is done in place.
184+
183185
Args:
184186
root_module (nn.Module): Root module relative to which `submodules` are referenced.
185187
submodules (list[str]): List of modules for which the parameters will be frozen. They are to be provided as
@@ -214,6 +216,7 @@ def freeze(root_module, submodules=[], include_bn_running_stats=True):
214216
def unfreeze(root_module, submodules=[], include_bn_running_stats=True):
215217
"""
216218
Unfreeze parameters of the specified modules and those of all their hierarchical descendants. This is done in place.
219+
217220
Args:
218221
root_module (nn.Module): Root module relative to which `submodules` are referenced.
219222
submodules (list[str]): List of submodules for which the parameters will be (un)frozen. They are to be provided

0 commit comments

Comments
 (0)