Skip to content

Commit

Permalink
[Docs] Add shortcycle sampler docs (open-mmlab#1513)
Browse files Browse the repository at this point in the history
* master

* master 0721

* add README

* 1231 bump_version

* 0207 slowfast steplr

* 0207

* add shortcycle sampler docs

* add shortcycle sampler docs

* add shortcycle sampler docs

* add shortcycle sampler docs
  • Loading branch information
gengenkai authored Mar 14, 2022
1 parent 4ce921b commit 63554dd
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 4 additions & 5 deletions mmaction/utils/multigrid/longshortcyclehook.py
Original file line number Diff line number Diff line change
@@ -12,8 +12,8 @@

def modify_subbn3d_num_splits(logger, module, num_splits):
"""Recursively modify the number of splits of subbn3ds in module.
Inheritates the running_mean and running_var from last subbn.bn.
Args:
logger (:obj:`logging.Logger`): The logger to log information.
module (nn.Module): The module to be modified.
@@ -30,7 +30,6 @@ def modify_subbn3d_num_splits(logger, module, num_splits):
new_state_dict = new_split_bn.state_dict()

for param_name, param in child.bn.state_dict().items():
# print('param_name', param_name, param.size())
origin_param_shape = param.size()
new_param_shape = new_state_dict[param_name].size()
if len(origin_param_shape) == 1 and len(
@@ -59,6 +58,7 @@ class LongShortCycleHook(Hook):
This hook defines multigrid training schedule and update cfg
accordingly, which is proposed in `A Multigrid Method for Efficiently
Training Video Models <https://arxiv.org/abs/1912.00998>`_.
Args:
cfg (:obj:`mmcv.ConfigDictg`): The whole config for the experiment.
"""
@@ -148,7 +148,6 @@ def _get_long_cycle_schedule(self, runner, cfg):
base_t = int(round(self.default_t * t_factor))
base_s = int(round(self.default_s * s_factor))
if cfg.short_cycle:
# shape = [#frames, scale]
shapes = [[
base_t,
int(round(self.default_s * cfg.short_cycle_factors[0]))
@@ -228,11 +227,11 @@ def _get_schedule(self, epoch):
return self.schedule[-1][1]

def _init_schedule(self, runner, multi_grid_cfg, data_cfg):
"""Initialize the multi-grid shcedule.
"""Initialize the multigrid shcedule.
Args:
runner (:obj: `mmcv.Runner`): The runner within which to train.
multi_grid_cfg (:obj: `mmcv.ConfigDict`): The multi-grid config.
multi_grid_cfg (:obj: `mmcv.ConfigDict`): The multigrid config.
data_cfg (:obj: `mmcv.ConfigDict`): The data config.
"""
self.default_bs = data_cfg.videos_per_gpu
8 changes: 8 additions & 0 deletions mmaction/utils/multigrid/short_sampler.py
Original file line number Diff line number Diff line change
@@ -8,6 +8,14 @@ class ShortCycleSampler(Sampler):
See paper "A Multigrid Method for Efficiently Training Video Models", Wu et
al., 2019 (https://arxiv.org/abs/1912.00998) for details.
Args:
sampler (:obj: `torch.Sampler`): The default sampler to be warpped.
batch_size (int): The batchsize before short-cycle modification.
multi_grid_cfg (dict): The config dict for multigrid training.
crop_size (int): The actual spatial scale.
drop_last (bool): Whether to drop the last incomplete batch in epoch.
Default: True.
"""

def __init__(self,

0 comments on commit 63554dd

Please sign in to comment.