code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def load_original_weights(self, logger): """Load weights from original checkpoint, which required converting keys.""" state_dict_torchvision = _load_checkpoint( self.pretrained, map_location='cpu') if 'state_dict' in state_dict_torchvision: state_dict_torchvision ...
Load weights from original checkpoint, which required converting keys.
load_original_weights
python
open-mmlab/mmaction2
mmaction/models/backbones/resnet_tsm.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/resnet_tsm.py
Apache-2.0
def init_weights(self): """Initiate the parameters either from existing checkpoint or from scratch.""" if self.pretrained2d: logger = MMLogger.get_current_instance() self.load_original_weights(logger) else: if self.pretrained: self.init...
Initiate the parameters either from existing checkpoint or from scratch.
init_weights
python
open-mmlab/mmaction2
mmaction/models/backbones/resnet_tsm.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/resnet_tsm.py
Apache-2.0
def init_weights(self) -> None: """Initiate the parameters either from existing checkpoint or from scratch.""" for m in self.modules(): if isinstance(m, nn.Conv3d): kaiming_init(m) elif isinstance(m, _BatchNorm): constant_init(m, 1) ...
Initiate the parameters either from existing checkpoint or from scratch.
init_weights
python
open-mmlab/mmaction2
mmaction/models/backbones/rgbposeconv3d.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/rgbposeconv3d.py
Apache-2.0
def forward(self, imgs: torch.Tensor, heatmap_imgs: torch.Tensor) -> tuple: """Defines the computation performed at every call. Args: imgs (torch.Tensor): The input data. heatmap_imgs (torch.Tensor): The input data. Returns: tuple[torch.Tensor]: The feature ...
Defines the computation performed at every call. Args: imgs (torch.Tensor): The input data. heatmap_imgs (torch.Tensor): The input data. Returns: tuple[torch.Tensor]: The feature of the input samples extracted by the backbone.
forward
python
open-mmlab/mmaction2
mmaction/models/backbones/rgbposeconv3d.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/rgbposeconv3d.py
Apache-2.0
def forward(self, x: torch.Tensor) -> torch.Tensor: """Defines the computation performed at every call.""" res = self.residual(x) x = self.tcn(self.gcn(x)) + res return self.relu(x)
Defines the computation performed at every call.
forward
python
open-mmlab/mmaction2
mmaction/models/backbones/stgcn.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/stgcn.py
Apache-2.0
def forward(self, x: torch.Tensor) -> torch.Tensor: """Defines the computation performed at every call.""" N, M, T, V, C = x.size() x = x.permute(0, 1, 3, 4, 2).contiguous() if self.data_bn_type == 'MVC': x = self.data_bn(x.view(N, M * V * C, T)) else: x =...
Defines the computation performed at every call.
forward
python
open-mmlab/mmaction2
mmaction/models/backbones/stgcn.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/stgcn.py
Apache-2.0
def window_partition(x: torch.Tensor, window_size: Sequence[int]) -> torch.Tensor: """ Args: x (torch.Tensor): The input features of shape :math:`(B, D, H, W, C)`. window_size (Sequence[int]): The window size, :math:`(w_d, w_h, w_w)`. Returns: torch.Tensor: The ...
Args: x (torch.Tensor): The input features of shape :math:`(B, D, H, W, C)`. window_size (Sequence[int]): The window size, :math:`(w_d, w_h, w_w)`. Returns: torch.Tensor: The partitioned windows of shape :math:`(B*num_windows, w_d*w_h*w_w, C)`.
window_partition
python
open-mmlab/mmaction2
mmaction/models/backbones/swin.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/swin.py
Apache-2.0
def window_reverse(windows: torch.Tensor, window_size: Sequence[int], B: int, D: int, H: int, W: int) -> torch.Tensor: """ Args: windows (torch.Tensor): Input windows of shape :meth:`(B*num_windows, w_d, w_h, w_w, C)`. window_size (Sequence[int]): The window size, ...
Args: windows (torch.Tensor): Input windows of shape :meth:`(B*num_windows, w_d, w_h, w_w, C)`. window_size (Sequence[int]): The window size, :meth:`(w_d, w_h, w_w)`. B (int): Batch size of feature maps. D (int): Temporal length of feature maps. H (int): Height o...
window_reverse
python
open-mmlab/mmaction2
mmaction/models/backbones/swin.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/swin.py
Apache-2.0
def get_window_size( x_size: Sequence[int], window_size: Sequence[int], shift_size: Optional[Sequence[int]] = None ) -> Union[Tuple[int], Tuple[Tuple[int]]]: """Calculate window size and shift size according to the input size. Args: x_size (Sequence[int]): The input size. window_siz...
Calculate window size and shift size according to the input size. Args: x_size (Sequence[int]): The input size. window_size (Sequence[int]): The expected window size. shift_size (Sequence[int], optional): The expected shift size. Defaults to None. Returns: tuple: Th...
get_window_size
python
open-mmlab/mmaction2
mmaction/models/backbones/swin.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/swin.py
Apache-2.0
def compute_mask(D: int, H: int, W: int, window_size: Sequence[int], shift_size: Sequence[int], device: Union[str, torch.device]) -> torch.Tensor: """Compute attention mask. Args: D (int): Temporal length of feature maps. H (int): Height of feature maps. ...
Compute attention mask. Args: D (int): Temporal length of feature maps. H (int): Height of feature maps. W (int): Width of feature maps. window_size (Sequence[int]): The window size. shift_size (Sequence[int]): The shift size. device (str or :obj:`torch.device`): The...
compute_mask
python
open-mmlab/mmaction2
mmaction/models/backbones/swin.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/swin.py
Apache-2.0
def forward(self, x: torch.Tensor, mask: Optional[torch.Tensor] = None) -> torch.Tensor: """Forward function. Args: x (torch.Tensor): Input feature maps of shape :meth:`(B*num_windows, N, C)`. mask (torch.Tensor, optional): (0/-inf...
Forward function. Args: x (torch.Tensor): Input feature maps of shape :meth:`(B*num_windows, N, C)`. mask (torch.Tensor, optional): (0/-inf) mask of shape :meth:`(num_windows, N, N)`. Defaults to None.
forward
python
open-mmlab/mmaction2
mmaction/models/backbones/swin.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/swin.py
Apache-2.0
def forward(self, x: torch.Tensor, mask_matrix: torch.Tensor) -> torch.Tensor: """ Args: x (torch.Tensor): Input features of shape :math:`(B, D, H, W, C)`. mask_matrix (torch.Tensor): Attention mask for cyclic shift. """ shortcut = x if se...
Args: x (torch.Tensor): Input features of shape :math:`(B, D, H, W, C)`. mask_matrix (torch.Tensor): Attention mask for cyclic shift.
forward
python
open-mmlab/mmaction2
mmaction/models/backbones/swin.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/swin.py
Apache-2.0
def forward(self, x: torch.Tensor) -> torch.Tensor: """Perform patch merging. Args: x (torch.Tensor): Input feature maps of shape :math:`(B, D, H, W, C)`. Returns: torch.Tensor: The merged feature maps of shape :math:`(B, D, H/2, W/2, 2*C...
Perform patch merging. Args: x (torch.Tensor): Input feature maps of shape :math:`(B, D, H, W, C)`. Returns: torch.Tensor: The merged feature maps of shape :math:`(B, D, H/2, W/2, 2*C)`.
forward
python
open-mmlab/mmaction2
mmaction/models/backbones/swin.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/swin.py
Apache-2.0
def forward(self, x: torch.Tensor, do_downsample: bool = True) -> torch.Tensor: """Forward function. Args: x (torch.Tensor): Input feature maps of shape :math:`(B, C, D, H, W)`. do_downsample (bool): Whether to downsample the outpu...
Forward function. Args: x (torch.Tensor): Input feature maps of shape :math:`(B, C, D, H, W)`. do_downsample (bool): Whether to downsample the output of the current layer. Defaults to True.
forward
python
open-mmlab/mmaction2
mmaction/models/backbones/swin.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/swin.py
Apache-2.0
def forward(self, x: torch.Tensor) -> torch.Tensor: """Perform video to patch embedding. Args: x (torch.Tensor): The input videos of shape :math:`(B, C, D, H, W)`. In most cases, C is 3. Returns: torch.Tensor: The video patches of shape :...
Perform video to patch embedding. Args: x (torch.Tensor): The input videos of shape :math:`(B, C, D, H, W)`. In most cases, C is 3. Returns: torch.Tensor: The video patches of shape :math:`(B, embed_dims, Dp, Hp, Wp)`.
forward
python
open-mmlab/mmaction2
mmaction/models/backbones/swin.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/swin.py
Apache-2.0
def _freeze_stages(self) -> None: """Prevent all the parameters from being optimized before ``self.frozen_stages``.""" if self.frozen_stages >= 0: self.patch_embed.eval() for param in self.patch_embed.parameters(): param.requires_grad = False if s...
Prevent all the parameters from being optimized before ``self.frozen_stages``.
_freeze_stages
python
open-mmlab/mmaction2
mmaction/models/backbones/swin.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/swin.py
Apache-2.0
def inflate_weights(self, logger: MMLogger) -> None: """Inflate the swin2d parameters to swin3d. The differences between swin3d and swin2d mainly lie in an extra axis. To utilize the pretrained parameters in 2d model, the weight of swin2d models should be inflated to fit in the shapes o...
Inflate the swin2d parameters to swin3d. The differences between swin3d and swin2d mainly lie in an extra axis. To utilize the pretrained parameters in 2d model, the weight of swin2d models should be inflated to fit in the shapes of the 3d counterpart. Args: logger ...
inflate_weights
python
open-mmlab/mmaction2
mmaction/models/backbones/swin.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/swin.py
Apache-2.0
def forward(self, x: torch.Tensor) -> torch.Tensor: """Defines the computation performed at every call.""" assert isinstance(self.block, Bottleneck) def _inner_forward(x): """Forward wrapper for utilizing checkpoint.""" identity = x out = self.block.conv1(x)...
Defines the computation performed at every call.
forward
python
open-mmlab/mmaction2
mmaction/models/backbones/tanet.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/tanet.py
Apache-2.0
def make_tam_modeling(self): """Replace ResNet-Block with TA-Block.""" def make_tam_block(stage, num_segments, tam_cfg=dict()): blocks = list(stage.children()) for i, block in enumerate(blocks): blocks[i] = TABlock(block, num_segments, deepcopy(tam_cfg)) ...
Replace ResNet-Block with TA-Block.
make_tam_modeling
python
open-mmlab/mmaction2
mmaction/models/backbones/tanet.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/tanet.py
Apache-2.0
def forward(self, x): """Defines the computation performed at every call. Args: x (Tensor): The input data. Returns: Tensor: The output of the module. """ x = rearrange(x, 'b c t h w -> (b t) c h w') x = self.projection(x).flatten(2).transpose(1,...
Defines the computation performed at every call. Args: x (Tensor): The input data. Returns: Tensor: The output of the module.
forward
python
open-mmlab/mmaction2
mmaction/models/backbones/timesformer.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/timesformer.py
Apache-2.0
def init_weights(self, pretrained=None): """Initiate the parameters either from existing checkpoint or from scratch.""" trunc_normal_(self.pos_embed, std=.02) trunc_normal_(self.cls_token, std=.02) if pretrained: self.pretrained = pretrained if isinstance(sel...
Initiate the parameters either from existing checkpoint or from scratch.
init_weights
python
open-mmlab/mmaction2
mmaction/models/backbones/timesformer.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/timesformer.py
Apache-2.0
def forward(self, x): """Defines the computation performed at every call.""" # x [batch_size * num_frames, num_patches, embed_dims] batches = x.shape[0] x = self.patch_embed(x) # x [batch_size * num_frames, num_patches + 1, embed_dims] cls_tokens = self.cls_token.expand(...
Defines the computation performed at every call.
forward
python
open-mmlab/mmaction2
mmaction/models/backbones/timesformer.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/timesformer.py
Apache-2.0
def conv_3xnxn(inp: int, oup: int, kernel_size: int = 3, stride: int = 3, groups: int = 1): """3D convolution with kernel size of 3xnxn. Args: inp (int): Dimension of input features. oup (int): Dimension of output features. ker...
3D convolution with kernel size of 3xnxn. Args: inp (int): Dimension of input features. oup (int): Dimension of output features. kernel_size (int): The spatial kernel size (i.e., n). Defaults to 3. stride (int): The spatial stride. Defaults to 3. grou...
conv_3xnxn
python
open-mmlab/mmaction2
mmaction/models/backbones/uniformer.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/uniformer.py
Apache-2.0
def conv_1xnxn(inp: int, oup: int, kernel_size: int = 3, stride: int = 3, groups: int = 1): """3D convolution with kernel size of 1xnxn. Args: inp (int): Dimension of input features. oup (int): Dimension of output features. ker...
3D convolution with kernel size of 1xnxn. Args: inp (int): Dimension of input features. oup (int): Dimension of output features. kernel_size (int): The spatial kernel size (i.e., n). Defaults to 3. stride (int): The spatial stride. Defaults to 3. grou...
conv_1xnxn
python
open-mmlab/mmaction2
mmaction/models/backbones/uniformer.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/uniformer.py
Apache-2.0
def _load_pretrained(self, pretrained: str = None) -> None: """Load ImageNet-1K pretrained model. The model is pretrained with ImageNet-1K. https://github.com/Sense-X/UniFormer Args: pretrained (str): Model name of ImageNet-1K pretrained model. Defaults to N...
Load ImageNet-1K pretrained model. The model is pretrained with ImageNet-1K. https://github.com/Sense-X/UniFormer Args: pretrained (str): Model name of ImageNet-1K pretrained model. Defaults to None.
_load_pretrained
python
open-mmlab/mmaction2
mmaction/models/backbones/uniformer.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/uniformer.py
Apache-2.0
def _load_pretrained(self, pretrained: str = None) -> None: """Load CLIP pretrained visual encoder. The visual encoder is extracted from CLIP. https://github.com/openai/CLIP Args: pretrained (str): Model name of pretrained CLIP visual encoder. Defaults to No...
Load CLIP pretrained visual encoder. The visual encoder is extracted from CLIP. https://github.com/openai/CLIP Args: pretrained (str): Model name of pretrained CLIP visual encoder. Defaults to None.
_load_pretrained
python
open-mmlab/mmaction2
mmaction/models/backbones/uniformerv2.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/uniformerv2.py
Apache-2.0
def forward(self, x: Tensor) -> Tensor: """Defines the computation performed at every call. Args: x (Tensor): The input data with size of (B, N, C). Returns: Tensor: The output of the attention block, same size as inputs. """ B, N, C = x.shape if...
Defines the computation performed at every call. Args: x (Tensor): The input data with size of (B, N, C). Returns: Tensor: The output of the attention block, same size as inputs.
forward
python
open-mmlab/mmaction2
mmaction/models/backbones/vit_mae.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/vit_mae.py
Apache-2.0
def forward(self, x: Tensor) -> Tensor: """Defines the computation performed at every call. Args: x (Tensor): The input data with size of (B, N, C). Returns: Tensor: The output of the transformer block, same size as inputs. """ if hasattr(self, 'gamma_1')...
Defines the computation performed at every call. Args: x (Tensor): The input data with size of (B, N, C). Returns: Tensor: The output of the transformer block, same size as inputs.
forward
python
open-mmlab/mmaction2
mmaction/models/backbones/vit_mae.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/vit_mae.py
Apache-2.0
def get_sinusoid_encoding(n_position: int, embed_dims: int) -> Tensor: """Generate sinusoid encoding table. Sinusoid encoding is a kind of relative position encoding method came from `Attention Is All You Need<https://arxiv.org/abs/1706.03762>`_. Args: n_position (int): The length of the input ...
Generate sinusoid encoding table. Sinusoid encoding is a kind of relative position encoding method came from `Attention Is All You Need<https://arxiv.org/abs/1706.03762>`_. Args: n_position (int): The length of the input token. embed_dims (int): The position embedding dimension. Returns...
get_sinusoid_encoding
python
open-mmlab/mmaction2
mmaction/models/backbones/vit_mae.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/vit_mae.py
Apache-2.0
def forward(self, x: Tensor) -> Tensor: """Defines the computation performed at every call. Args: x (Tensor): The input data. Returns: Tensor: The feature of the input samples extracted by the backbone. """ b, _, _, h, w = x.shape ...
Defines the computation performed at every call. Args: x (Tensor): The input data. Returns: Tensor: The feature of the input samples extracted by the backbone.
forward
python
open-mmlab/mmaction2
mmaction/models/backbones/vit_mae.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/vit_mae.py
Apache-2.0
def _round_width(width, multiplier, min_width=8, divisor=8): """Round width of filters based on width multiplier.""" width *= multiplier min_width = min_width or divisor width_out = max(min_width, int(width + divisor / 2) // divisor * divisor) if width_out...
Round width of filters based on width multiplier.
_round_width
python
open-mmlab/mmaction2
mmaction/models/backbones/x3d.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/x3d.py
Apache-2.0
def forward(self, x): """Defines the computation performed at every call. Args: x (Tensor): The input data. Returns: Tensor: The output of the module. """ module_input = x x = self.avg_pool(x) x = self.fc1(x) x = self.relu(x) ...
Defines the computation performed at every call. Args: x (Tensor): The input data. Returns: Tensor: The output of the module.
forward
python
open-mmlab/mmaction2
mmaction/models/backbones/x3d.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/x3d.py
Apache-2.0
def forward(self, x): """Defines the computation performed at every call.""" def _inner_forward(x): """Forward wrapper for utilizing checkpoint.""" identity = x out = self.conv1(x) out = self.conv2(out) if self.se_ratio is not None: ...
Defines the computation performed at every call.
forward
python
open-mmlab/mmaction2
mmaction/models/backbones/x3d.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/x3d.py
Apache-2.0
def _round_width(width, multiplier, min_depth=8, divisor=8): """Round width of filters based on width multiplier.""" if not multiplier: return width width *= multiplier min_depth = min_depth or divisor new_filters = max(min_depth, int(width ...
Round width of filters based on width multiplier.
_round_width
python
open-mmlab/mmaction2
mmaction/models/backbones/x3d.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/x3d.py
Apache-2.0
def _round_repeats(repeats, multiplier): """Round number of layers based on depth multiplier.""" if not multiplier: return repeats return int(math.ceil(multiplier * repeats))
Round number of layers based on depth multiplier.
_round_repeats
python
open-mmlab/mmaction2
mmaction/models/backbones/x3d.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/x3d.py
Apache-2.0
def make_res_layer(self, block, layer_inplanes, inplanes, planes, blocks, spatial_stride=1, se_style='half', se_ratio=None, ...
Build residual layer for ResNet3D. Args: block (nn.Module): Residual module to be built. layer_inplanes (int): Number of channels for the input feature of the res layer. inplanes (int): Number of channels for the input feature in each block, w...
make_res_layer
python
open-mmlab/mmaction2
mmaction/models/backbones/x3d.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/x3d.py
Apache-2.0
def _make_stem_layer(self): """Construct the stem layers consists of a conv+norm+act module and a pooling layer.""" self.conv1_s = ConvModule( self.in_channels, self.base_channels, kernel_size=(1, 3, 3), stride=(1, 2, 2), padding=(0, 1,...
Construct the stem layers consists of a conv+norm+act module and a pooling layer.
_make_stem_layer
python
open-mmlab/mmaction2
mmaction/models/backbones/x3d.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/x3d.py
Apache-2.0
def _freeze_stages(self): """Prevent all the parameters from being optimized before ``self.frozen_stages``.""" if self.frozen_stages >= 0: self.conv1_s.eval() self.conv1_t.eval() for param in self.conv1_s.parameters(): param.requires_grad = Fal...
Prevent all the parameters from being optimized before ``self.frozen_stages``.
_freeze_stages
python
open-mmlab/mmaction2
mmaction/models/backbones/x3d.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/x3d.py
Apache-2.0
def init_weights(self): """Initiate the parameters either from existing checkpoint or from scratch.""" if isinstance(self.pretrained, str): logger = MMLogger.get_current_instance() logger.info(f'load model from: {self.pretrained}') load_checkpoint(self, self....
Initiate the parameters either from existing checkpoint or from scratch.
init_weights
python
open-mmlab/mmaction2
mmaction/models/backbones/x3d.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/x3d.py
Apache-2.0
def forward(self, x): """Defines the computation performed at every call. Args: x (torch.Tensor): The input data. Returns: torch.Tensor: The feature of the input samples extracted by the backbone. """ x = self.conv1_s(x) x = self.conv...
Defines the computation performed at every call. Args: x (torch.Tensor): The input data. Returns: torch.Tensor: The feature of the input samples extracted by the backbone.
forward
python
open-mmlab/mmaction2
mmaction/models/backbones/x3d.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/x3d.py
Apache-2.0
def train(self, mode=True): """Set the optimization status when training.""" super().train(mode) self._freeze_stages() if mode and self.norm_eval: for m in self.modules(): if isinstance(m, _BatchNorm): m.eval()
Set the optimization status when training.
train
python
open-mmlab/mmaction2
mmaction/models/backbones/x3d.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/backbones/x3d.py
Apache-2.0
def forward(self, x: torch.Tensor) -> torch.Tensor: """Defines the computation performed at every call. Args: x (torch.Tensor): The input data. Returns: torch.Tensor: The output of the module. """ x = self.conv_s(x) x = self.bn_s(x) x = s...
Defines the computation performed at every call. Args: x (torch.Tensor): The input data. Returns: torch.Tensor: The output of the module.
forward
python
open-mmlab/mmaction2
mmaction/models/common/conv2plus1d.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/common/conv2plus1d.py
Apache-2.0
def forward(self, x: torch.Tensor) -> torch.Tensor: """Defines the computation performed at every call. Args: x (torch.Tensor): The input data. Returns: torch.Tensor: The output of the module. """ x_1 = self.conv_1(x) x_2 = self.conv_2(x) ...
Defines the computation performed at every call. Args: x (torch.Tensor): The input data. Returns: torch.Tensor: The output of the module.
forward
python
open-mmlab/mmaction2
mmaction/models/common/conv_audio.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/common/conv_audio.py
Apache-2.0
def aggregate_stats(self): """Synchronize running_mean, and running_var to self.bn. Call this before eval, then call model.eval(); When eval, forward function will call self.bn instead of self.split_bn, During this time the running_mean, and running_var of self.bn has been obtained from...
Synchronize running_mean, and running_var to self.bn. Call this before eval, then call model.eval(); When eval, forward function will call self.bn instead of self.split_bn, During this time the running_mean, and running_var of self.bn has been obtained from self.split_bn.
aggregate_stats
python
open-mmlab/mmaction2
mmaction/models/common/sub_batchnorm3d.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/common/sub_batchnorm3d.py
Apache-2.0
def forward(self, x): """Defines the computation performed at every call.""" if self.training: n, c, t, h, w = x.shape assert n % self.num_splits == 0 x = x.view(n // self.num_splits, c * self.num_splits, t, h, w) x = self.split_bn(x) x = x.vie...
Defines the computation performed at every call.
forward
python
open-mmlab/mmaction2
mmaction/models/common/sub_batchnorm3d.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/common/sub_batchnorm3d.py
Apache-2.0
def forward(self, x: torch.Tensor) -> torch.Tensor: """Defines the computation performed at every call. Args: x (torch.Tensor): The input data. Returns: torch.Tensor: The output of the module. """ # [n, c, h, w] n, c, h, w = x.size() num_...
Defines the computation performed at every call. Args: x (torch.Tensor): The input data. Returns: torch.Tensor: The output of the module.
forward
python
open-mmlab/mmaction2
mmaction/models/common/tam.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/common/tam.py
Apache-2.0
def forward(self, query, key=None, value=None, residual=None, **kwargs): """Defines the computation performed at every call.""" assert residual is None, ( 'Always adding the shortcut in the forward function') init_cls_token = query[:, 0, :].unsqueeze(1) identity = query_t = ...
Defines the computation performed at every call.
forward
python
open-mmlab/mmaction2
mmaction/models/common/transformer.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/common/transformer.py
Apache-2.0
def forward(self, query, key=None, value=None, residual=None, **kwargs): """Defines the computation performed at every call.""" assert residual is None, ( 'Always adding the shortcut in the forward function') identity = query init_cls_token = query[:, 0, :].unsqueeze(1) ...
Defines the computation performed at every call.
forward
python
open-mmlab/mmaction2
mmaction/models/common/transformer.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/common/transformer.py
Apache-2.0
def forward(self, x, residual=None): """Defines the computation performed at every call.""" assert residual is None, ('Cannot apply pre-norm with FFNWithNorm') return super().forward(self.norm(x), x)
Defines the computation performed at every call.
forward
python
open-mmlab/mmaction2
mmaction/models/common/transformer.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/common/transformer.py
Apache-2.0
def forward(self, data: Union[dict, Tuple[dict]], training: bool = False) -> Union[dict, Tuple[dict]]: """Perform normalization, padding, bgr2rgb conversion and batch augmentation based on ``BaseDataPreprocessor``. Args: data (dict or Tuple[dict]): da...
Perform normalization, padding, bgr2rgb conversion and batch augmentation based on ``BaseDataPreprocessor``. Args: data (dict or Tuple[dict]): data sampled from dataloader. training (bool): Whether to enable training time augmentation. Returns: dict or Tuple...
forward
python
open-mmlab/mmaction2
mmaction/models/data_preprocessors/data_preprocessor.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/data_preprocessors/data_preprocessor.py
Apache-2.0
def forward_onesample(self, data, training: bool = False) -> dict: """Perform normalization, padding, bgr2rgb conversion and batch augmentation on one data sample. Args: data (dict): data sampled from dataloader. training (bool): Whether to enable training time augmentat...
Perform normalization, padding, bgr2rgb conversion and batch augmentation on one data sample. Args: data (dict): data sampled from dataloader. training (bool): Whether to enable training time augmentation. Returns: dict: Data in the same format as the model ...
forward_onesample
python
open-mmlab/mmaction2
mmaction/models/data_preprocessors/data_preprocessor.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/data_preprocessors/data_preprocessor.py
Apache-2.0
def forward(self, data: Dict, training: bool = False) -> Dict: """Preprocesses the data into the model input format. Args: data (dict): Data returned by dataloader. training (bool): Whether to enable training time augmentation. Returns: dict: Data in the sam...
Preprocesses the data into the model input format. Args: data (dict): Data returned by dataloader. training (bool): Whether to enable training time augmentation. Returns: dict: Data in the same format as the model input.
forward
python
open-mmlab/mmaction2
mmaction/models/data_preprocessors/multimodal_data_preprocessor.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/data_preprocessors/multimodal_data_preprocessor.py
Apache-2.0
def loss(self, feats: Union[torch.Tensor, Tuple[torch.Tensor]], data_samples: SampleList, **kwargs) -> Dict: """Perform forward propagation of head and loss calculation on the features of the upstream network. Args: feats (torch.Tensor | tuple[torch.Tensor]): Features f...
Perform forward propagation of head and loss calculation on the features of the upstream network. Args: feats (torch.Tensor | tuple[torch.Tensor]): Features from upstream network. data_samples (list[:obj:`ActionDataSample`]): The batch data sample...
loss
python
open-mmlab/mmaction2
mmaction/models/heads/base.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/heads/base.py
Apache-2.0
def loss_by_feat(self, cls_scores: torch.Tensor, data_samples: SampleList) -> Dict: """Calculate the loss based on the features extracted by the head. Args: cls_scores (torch.Tensor): Classification prediction results of all class, has shape (batch_size,...
Calculate the loss based on the features extracted by the head. Args: cls_scores (torch.Tensor): Classification prediction results of all class, has shape (batch_size, num_classes). data_samples (list[:obj:`ActionDataSample`]): The batch data samples. ...
loss_by_feat
python
open-mmlab/mmaction2
mmaction/models/heads/base.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/heads/base.py
Apache-2.0
def predict(self, feats: Union[torch.Tensor, Tuple[torch.Tensor]], data_samples: SampleList, **kwargs) -> SampleList: """Perform forward propagation of head and predict recognition results on the features of the upstream network. Args: feats (torch.Tensor | tuple[tor...
Perform forward propagation of head and predict recognition results on the features of the upstream network. Args: feats (torch.Tensor | tuple[torch.Tensor]): Features from upstream network. data_samples (list[:obj:`ActionDataSample`]): The batch ...
predict
python
open-mmlab/mmaction2
mmaction/models/heads/base.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/heads/base.py
Apache-2.0
def predict_by_feat(self, cls_scores: torch.Tensor, data_samples: SampleList) -> SampleList: """Transform a batch of output features extracted from the head into prediction results. Args: cls_scores (torch.Tensor): Classification scores, has a shape ...
Transform a batch of output features extracted from the head into prediction results. Args: cls_scores (torch.Tensor): Classification scores, has a shape (B*num_segs, num_classes) data_samples (list[:obj:`ActionDataSample`]): The annotation data o...
predict_by_feat
python
open-mmlab/mmaction2
mmaction/models/heads/base.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/heads/base.py
Apache-2.0
def average_clip(self, cls_scores: torch.Tensor, num_segs: int = 1) -> torch.Tensor: """Averaging class scores over multiple clips. Using different averaging types ('score' or 'prob' or None, which defined in test_cfg) to computed the final averaged ...
Averaging class scores over multiple clips. Using different averaging types ('score' or 'prob' or None, which defined in test_cfg) to computed the final averaged class score. Only called in test mode. Args: cls_scores (torch.Tensor): Class scores to be averaged. ...
average_clip
python
open-mmlab/mmaction2
mmaction/models/heads/base.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/heads/base.py
Apache-2.0
def forward(self, x: Tensor, num_segs: Optional[int] = None, **kwargs) -> Tensor: """Defines the computation performed at every call. Args: x (Tensor): The input data. num_segs (int): For 2D backbone. Number of segments into which ...
Defines the computation performed at every call. Args: x (Tensor): The input data. num_segs (int): For 2D backbone. Number of segments into which a video is divided. Defaults to None. Returns: Tensor: The output features after pooling.
forward
python
open-mmlab/mmaction2
mmaction/models/heads/feature_head.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/heads/feature_head.py
Apache-2.0
def predict_by_feat(self, feats: Union[Tensor, Tuple[Tensor]], data_samples) -> Tensor: """Integrate multi-view features into one tensor. Args: feats (torch.Tensor | tuple[torch.Tensor]): Features from upstream network. data_samples (list[...
Integrate multi-view features into one tensor. Args: feats (torch.Tensor | tuple[torch.Tensor]): Features from upstream network. data_samples (list[:obj:`ActionDataSample`]): The batch data samples. Returns: Tensor: The integrated mul...
predict_by_feat
python
open-mmlab/mmaction2
mmaction/models/heads/feature_head.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/heads/feature_head.py
Apache-2.0
def forward(self, x: torch.Tensor, **kwargs) -> torch.Tensor: """Forward features from the upstream network. Args: x (torch.Tensor): Features from the upstream network. Returns: torch.Tensor: Classification scores with shape (B, num_classes). """ N, M, ...
Forward features from the upstream network. Args: x (torch.Tensor): Features from the upstream network. Returns: torch.Tensor: Classification scores with shape (B, num_classes).
forward
python
open-mmlab/mmaction2
mmaction/models/heads/gcn_head.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/heads/gcn_head.py
Apache-2.0
def forward(self, x: Tensor, **kwargs) -> Tensor: """Defines the computation performed at every call. Args: x (Tensor): The input data. Returns: Tensor: The classification scores for input samples. """ # [N, in_channels, 4, 7, 7] if self.avg_pool...
Defines the computation performed at every call. Args: x (Tensor): The input data. Returns: Tensor: The classification scores for input samples.
forward
python
open-mmlab/mmaction2
mmaction/models/heads/i3d_head.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/heads/i3d_head.py
Apache-2.0
def pre_logits(self, feats: Tuple[List[Tensor]]) -> Tensor: """The process before the final classification head. The input ``feats`` is a tuple of list of tensor, and each tensor is the feature of a backbone stage. """ if self.with_cls_token: _, cls_token = feats[-1]...
The process before the final classification head. The input ``feats`` is a tuple of list of tensor, and each tensor is the feature of a backbone stage.
pre_logits
python
open-mmlab/mmaction2
mmaction/models/heads/mvit_head.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/heads/mvit_head.py
Apache-2.0
def forward(self, x: Tuple[List[Tensor]], **kwargs) -> Tensor: """Defines the computation performed at every call. Args: x (Tuple[List[Tensor]]): The input data. Returns: Tensor: The classification scores for input samples. """ x = self.pre_logits(x) ...
Defines the computation performed at every call. Args: x (Tuple[List[Tensor]]): The input data. Returns: Tensor: The classification scores for input samples.
forward
python
open-mmlab/mmaction2
mmaction/models/heads/mvit_head.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/heads/mvit_head.py
Apache-2.0
def forward(self, x: Tensor, **kwargs) -> Tensor: """Defines the computation performed at every call. Args: x (Tensor): The input data. Returns: Tensor: The classification scores for input samples. """ if len(x.shape) == 4: cls_score = self.f...
Defines the computation performed at every call. Args: x (Tensor): The input data. Returns: Tensor: The classification scores for input samples.
forward
python
open-mmlab/mmaction2
mmaction/models/heads/omni_head.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/heads/omni_head.py
Apache-2.0
def loss_by_feat(self, cls_scores: Union[Tensor, Tuple[Tensor]], data_samples: SampleList) -> dict: """Calculate the loss based on the features extracted by the head. Args: cls_scores (Tensor): Classification prediction results of all class, has shape (b...
Calculate the loss based on the features extracted by the head. Args: cls_scores (Tensor): Classification prediction results of all class, has shape (batch_size, num_classes). data_samples (List[:obj:`ActionDataSample`]): The batch data samples. ...
loss_by_feat
python
open-mmlab/mmaction2
mmaction/models/heads/omni_head.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/heads/omni_head.py
Apache-2.0
def forward(self, x: Tuple[torch.Tensor]) -> Dict: """Defines the computation performed at every call.""" x_rgb, x_pose = self.avg_pool(x[0]), self.avg_pool(x[1]) x_rgb = x_rgb.view(x_rgb.size(0), -1) x_pose = x_pose.view(x_pose.size(0), -1) x_rgb = self.dropout_rgb(x_rgb) ...
Defines the computation performed at every call.
forward
python
open-mmlab/mmaction2
mmaction/models/heads/rgbpose_head.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/heads/rgbpose_head.py
Apache-2.0
def loss(self, feats: Tuple[torch.Tensor], data_samples: SampleList, **kwargs) -> Dict: """Perform forward propagation of head and loss calculation on the features of the upstream network. Args: feats (tuple[torch.Tensor]): Features from upstream network. da...
Perform forward propagation of head and loss calculation on the features of the upstream network. Args: feats (tuple[torch.Tensor]): Features from upstream network. data_samples (list[:obj:`ActionDataSample`]): The batch data samples. Returns: ...
loss
python
open-mmlab/mmaction2
mmaction/models/heads/rgbpose_head.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/heads/rgbpose_head.py
Apache-2.0
def loss_by_feat(self, cls_scores: Dict[str, torch.Tensor], data_samples: SampleList) -> Dict: """Calculate the loss based on the features extracted by the head. Args: cls_scores (dict[str, torch.Tensor]): The dict of classification scores, d...
Calculate the loss based on the features extracted by the head. Args: cls_scores (dict[str, torch.Tensor]): The dict of classification scores, data_samples (list[:obj:`ActionDataSample`]): The batch data samples. Returns: dict: A dict...
loss_by_feat
python
open-mmlab/mmaction2
mmaction/models/heads/rgbpose_head.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/heads/rgbpose_head.py
Apache-2.0
def loss_by_scores(self, cls_scores: torch.Tensor, labels: torch.Tensor) -> Dict: """Calculate the loss based on the features extracted by the head. Args: cls_scores (torch.Tensor): Classification prediction results of all class, has shape (batch_size,...
Calculate the loss based on the features extracted by the head. Args: cls_scores (torch.Tensor): Classification prediction results of all class, has shape (batch_size, num_classes). labels (torch.Tensor): The labels used to calculate the loss. Returns: ...
loss_by_scores
python
open-mmlab/mmaction2
mmaction/models/heads/rgbpose_head.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/heads/rgbpose_head.py
Apache-2.0
def predict(self, feats: Tuple[torch.Tensor], data_samples: SampleList, **kwargs) -> SampleList: """Perform forward propagation of head and predict recognition results on the features of the upstream network. Args: feats (tuple[torch.Tensor]): Features from upstream ...
Perform forward propagation of head and predict recognition results on the features of the upstream network. Args: feats (tuple[torch.Tensor]): Features from upstream network. data_samples (list[:obj:`ActionDataSample`]): The batch data samples. Returns:...
predict
python
open-mmlab/mmaction2
mmaction/models/heads/rgbpose_head.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/heads/rgbpose_head.py
Apache-2.0
def predict_by_feat(self, cls_scores: Dict[str, torch.Tensor], data_samples: SampleList) -> SampleList: """Transform a batch of output features extracted from the head into prediction results. Args: cls_scores (dict[str, torch.Tensor]): The dict of ...
Transform a batch of output features extracted from the head into prediction results. Args: cls_scores (dict[str, torch.Tensor]): The dict of classification scores, data_samples (list[:obj:`ActionDataSample`]): The annotation data of every samples...
predict_by_feat
python
open-mmlab/mmaction2
mmaction/models/heads/rgbpose_head.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/heads/rgbpose_head.py
Apache-2.0
def predict_by_scores(self, cls_scores: torch.Tensor, data_samples: SampleList) -> torch.Tensor: """Transform a batch of output features extracted from the head into prediction results. Args: cls_scores (torch.Tensor): Classification scores, has a shape ...
Transform a batch of output features extracted from the head into prediction results. Args: cls_scores (torch.Tensor): Classification scores, has a shape (B*num_segs, num_classes) data_samples (list[:obj:`ActionDataSample`]): The annotation data o...
predict_by_scores
python
open-mmlab/mmaction2
mmaction/models/heads/rgbpose_head.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/heads/rgbpose_head.py
Apache-2.0
def forward(self, x: Tuple[Tensor], **kwargs) -> None: """Defines the computation performed at every call. Args: x (tuple[torch.Tensor]): The input data. Returns: Tensor: The classification scores for input samples. """ # ([N, channel_slow, T1, H, W], [(...
Defines the computation performed at every call. Args: x (tuple[torch.Tensor]): The input data. Returns: Tensor: The classification scores for input samples.
forward
python
open-mmlab/mmaction2
mmaction/models/heads/slowfast_head.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/heads/slowfast_head.py
Apache-2.0
def forward(self, x: Tensor, **kwargs) -> Tensor: """Defines the computation performed at every call. Args: x (Tensor): The input data. Returns: Tensor: The classification scores for input samples. """ # [N, in_channels] if self.dropout is not No...
Defines the computation performed at every call. Args: x (Tensor): The input data. Returns: Tensor: The classification scores for input samples.
forward
python
open-mmlab/mmaction2
mmaction/models/heads/timesformer_head.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/heads/timesformer_head.py
Apache-2.0
def forward(self, x, num_segs: Optional[int] = None, fcn_test: bool = False, **kwargs) -> Tensor: """Defines the computation performed at every call. Args: x (Tensor): The input data. num_segs (int, optional): Numbe...
Defines the computation performed at every call. Args: x (Tensor): The input data. num_segs (int, optional): Number of segments into which a video is divided. Defaults to None. fcn_test (bool): Whether to apply full convolution (fcn) testing. ...
forward
python
open-mmlab/mmaction2
mmaction/models/heads/tpn_head.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/heads/tpn_head.py
Apache-2.0
def forward(self, x): """Defines the computation performed at every call. Args: x (Tensor): The input data. Returns: Tensor: The classification scores for input samples. """ # [N, num_segs * hidden_dim] x = x.view(x.size(0), -1) x = self.c...
Defines the computation performed at every call. Args: x (Tensor): The input data. Returns: Tensor: The classification scores for input samples.
forward
python
open-mmlab/mmaction2
mmaction/models/heads/trn_head.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/heads/trn_head.py
Apache-2.0
def forward(self, x, num_segs, **kwargs): """Defines the computation performed at every call. Args: x (torch.Tensor): The input data. num_segs (int): Useless in TRNHead. By default, `num_segs` is equal to `clip_len * num_clips * num_crops`, which is ...
Defines the computation performed at every call. Args: x (torch.Tensor): The input data. num_segs (int): Useless in TRNHead. By default, `num_segs` is equal to `clip_len * num_clips * num_crops`, which is automatically generated in Recognizer forward phas...
forward
python
open-mmlab/mmaction2
mmaction/models/heads/trn_head.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/heads/trn_head.py
Apache-2.0
def forward(self, x: Tensor, num_segs: int, **kwargs) -> Tensor: """Defines the computation performed at every call. Args: x (Tensor): The input data. num_segs (int): Useless in TSMHead. By default, `num_segs` is equal to `clip_len * num_clips * num_crops`, which...
Defines the computation performed at every call. Args: x (Tensor): The input data. num_segs (int): Useless in TSMHead. By default, `num_segs` is equal to `clip_len * num_clips * num_crops`, which is automatically generated in Recognizer forward phase and ...
forward
python
open-mmlab/mmaction2
mmaction/models/heads/tsm_head.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/heads/tsm_head.py
Apache-2.0
def forward(self, x: torch.Tensor) -> torch.Tensor: """Defines the computation performed at every call. Args: x (torch.Tensor): The input data. Returns: torch.Tensor: The classification scores for input samples. """ # [N * num_segs, in_channels, h, w] ...
Defines the computation performed at every call. Args: x (torch.Tensor): The input data. Returns: torch.Tensor: The classification scores for input samples.
forward
python
open-mmlab/mmaction2
mmaction/models/heads/tsn_audio_head.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/heads/tsn_audio_head.py
Apache-2.0
def forward(self, x: Tensor, num_segs: int, **kwargs) -> Tensor: """Defines the computation performed at every call. Args: x (Tensor): The input data. num_segs (int): Number of segments into which a video is divided. Returns: Tensor: The class...
Defines the computation performed at every call. Args: x (Tensor): The input data. num_segs (int): Number of segments into which a video is divided. Returns: Tensor: The classification scores for input samples.
forward
python
open-mmlab/mmaction2
mmaction/models/heads/tsn_head.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/heads/tsn_head.py
Apache-2.0
def forward(self, x: Tensor, **kwargs) -> Tensor: """Defines the computation performed at every call. Args: x (Tensor): The input data. Returns: Tensor: The classification scores for input samples. """ # [N, in_channels] if self.dropout is not No...
Defines the computation performed at every call. Args: x (Tensor): The input data. Returns: Tensor: The classification scores for input samples.
forward
python
open-mmlab/mmaction2
mmaction/models/heads/uniformer_head.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/heads/uniformer_head.py
Apache-2.0
def forward(self, x: Tensor, **kwargs) -> Tensor: """Defines the computation performed at every call. Args: x (Tensor): The input data. Returns: Tensor: The classification scores for input samples. """ # [N, in_channels, T, H, W] assert self.pool...
Defines the computation performed at every call. Args: x (Tensor): The input data. Returns: Tensor: The classification scores for input samples.
forward
python
open-mmlab/mmaction2
mmaction/models/heads/x3d_head.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/heads/x3d_head.py
Apache-2.0
def forward(self, inputs, data_samples, mode, **kwargs): """The unified entry for a forward process in both training and test. The method should accept three modes: - ``tensor``: Forward the whole network and return tensor or tuple of tensor without any post-processing, same as a commo...
The unified entry for a forward process in both training and test. The method should accept three modes: - ``tensor``: Forward the whole network and return tensor or tuple of tensor without any post-processing, same as a common nn.Module. - ``predict``: Forward and return the predictio...
forward
python
open-mmlab/mmaction2
mmaction/models/localizers/bmn.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/localizers/bmn.py
Apache-2.0
def loss(self, batch_inputs, batch_data_samples, **kwargs): """Calculate losses from a batch of inputs and data samples. Args: batch_inputs (Tensor): Raw Inputs of the recognizer. These should usually be mean centered and std scaled. batch_data_samples (List[:obj...
Calculate losses from a batch of inputs and data samples. Args: batch_inputs (Tensor): Raw Inputs of the recognizer. These should usually be mean centered and std scaled. batch_data_samples (List[:obj:`ActionDataSample`]): The batch data samples. It usual...
loss
python
open-mmlab/mmaction2
mmaction/models/localizers/bmn.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/localizers/bmn.py
Apache-2.0
def predict(self, batch_inputs, batch_data_samples, **kwargs): """Define the computation performed at every call when testing.""" confidence_map, start, end = self._forward(batch_inputs) start_scores = start[0].cpu().numpy() end_scores = end[0].cpu().numpy() cls_confidence = (con...
Define the computation performed at every call when testing.
predict
python
open-mmlab/mmaction2
mmaction/models/localizers/bmn.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/localizers/bmn.py
Apache-2.0
def _get_interp1d_bin_mask(seg_tmin, seg_tmax, tscale, num_samples, num_samples_per_bin): """Generate sample mask for a boundary-matching pair.""" plen = float(seg_tmax - seg_tmin) plen_sample = plen / (num_samples * num_samples_per_bin - 1.0) total_samples...
Generate sample mask for a boundary-matching pair.
_get_interp1d_bin_mask
python
open-mmlab/mmaction2
mmaction/models/localizers/bmn.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/localizers/bmn.py
Apache-2.0
def _get_interp1d_mask(self): """Generate sample mask for each point in Boundary-Matching Map.""" mask_mat = [] for start_index in range(self.tscale): mask_mat_vector = [] for duration_index in range(self.tscale): if start_index + duration_index < self.tsc...
Generate sample mask for each point in Boundary-Matching Map.
_get_interp1d_mask
python
open-mmlab/mmaction2
mmaction/models/localizers/bmn.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/localizers/bmn.py
Apache-2.0
def _temporal_anchors(self, tmin_offset=0., tmax_offset=1.): """Generate temporal anchors. Args: tmin_offset (int): Offset for the minimum value of temporal anchor. Default: 0. tmax_offset (int): Offset for the maximum value of temporal anchor. De...
Generate temporal anchors. Args: tmin_offset (int): Offset for the minimum value of temporal anchor. Default: 0. tmax_offset (int): Offset for the maximum value of temporal anchor. Default: 1. Returns: tuple[Sequence[float]]: The minim...
_temporal_anchors
python
open-mmlab/mmaction2
mmaction/models/localizers/bmn.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/localizers/bmn.py
Apache-2.0
def _forward(self, x): """Define the computation performed at every call. Args: x (torch.Tensor): The input data. Returns: torch.Tensor: The output of the module. """ # x.shape [batch_size, self.feat_dim, self.tscale] base_feature = self.x_1d_b(x)...
Define the computation performed at every call. Args: x (torch.Tensor): The input data. Returns: torch.Tensor: The output of the module.
_forward
python
open-mmlab/mmaction2
mmaction/models/localizers/bmn.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/localizers/bmn.py
Apache-2.0
def init_weights(self) -> None: """Initiate the parameters either from existing checkpoint or from scratch.""" for m in self.modules(): if isinstance(m, nn.Conv2d): kaiming_init(m) elif isinstance(m, nn.BatchNorm2d): constant_init(m, 1)
Initiate the parameters either from existing checkpoint or from scratch.
init_weights
python
open-mmlab/mmaction2
mmaction/models/localizers/bsn.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/localizers/bsn.py
Apache-2.0
def _temporal_anchors(self, tmin_offset=0., tmax_offset=1.): """Generate temporal anchors. Args: tmin_offset (int): Offset for the minimum value of temporal anchor. Default: 0. tmax_offset (int): Offset for the maximum value of temporal anchor. De...
Generate temporal anchors. Args: tmin_offset (int): Offset for the minimum value of temporal anchor. Default: 0. tmax_offset (int): Offset for the maximum value of temporal anchor. Default: 1. Returns: tuple[Sequence[float]]: The minim...
_temporal_anchors
python
open-mmlab/mmaction2
mmaction/models/localizers/bsn.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/localizers/bsn.py
Apache-2.0
def _forward(self, x): """Define the computation performed at every call. Args: x (torch.Tensor): The input data. Returns: torch.Tensor: The output of the module. """ x = F.relu(self.conv1_ratio * self.conv1(x)) x = F.relu(self.conv2_ratio * self....
Define the computation performed at every call. Args: x (torch.Tensor): The input data. Returns: torch.Tensor: The output of the module.
_forward
python
open-mmlab/mmaction2
mmaction/models/localizers/bsn.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/localizers/bsn.py
Apache-2.0
def loss(self, batch_inputs, batch_data_samples, **kwargs): """Calculate losses from a batch of inputs and data samples. Args: batch_inputs (Tensor): Raw Inputs of the recognizer. These should usually be mean centered and std scaled. batch_data_samples (List[:obj...
Calculate losses from a batch of inputs and data samples. Args: batch_inputs (Tensor): Raw Inputs of the recognizer. These should usually be mean centered and std scaled. batch_data_samples (List[:obj:`ActionDataSample`]): The batch data samples. It usual...
loss
python
open-mmlab/mmaction2
mmaction/models/localizers/bsn.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/localizers/bsn.py
Apache-2.0
def predict(self, batch_inputs, batch_data_samples, **kwargs): """Define the computation performed at every call when testing.""" tem_output = self._forward(batch_inputs).cpu().numpy() batch_action = tem_output[:, 0, :] batch_start = tem_output[:, 1, :] batch_end = tem_output[:, ...
Define the computation performed at every call when testing.
predict
python
open-mmlab/mmaction2
mmaction/models/localizers/bsn.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/localizers/bsn.py
Apache-2.0
def forward(self, inputs, data_samples, mode, **kwargs): """The unified entry for a forward process in both training and test. The method should accept three modes: - ``tensor``: Forward the whole network and return tensor or tuple of tensor without any post-processing, same as a commo...
The unified entry for a forward process in both training and test. The method should accept three modes: - ``tensor``: Forward the whole network and return tensor or tuple of tensor without any post-processing, same as a common nn.Module. - ``predict``: Forward and return the predictio...
forward
python
open-mmlab/mmaction2
mmaction/models/localizers/bsn.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/localizers/bsn.py
Apache-2.0
def init_weights(self) -> None: """Initiate the parameters either from existing checkpoint or from scratch.""" for m in self.modules(): if isinstance(m, nn.Conv2d): kaiming_init(m) elif isinstance(m, nn.BatchNorm2d): constant_init(m, 1)
Initiate the parameters either from existing checkpoint or from scratch.
init_weights
python
open-mmlab/mmaction2
mmaction/models/localizers/bsn.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/localizers/bsn.py
Apache-2.0
def _forward(self, x): """Define the computation performed at every call. Args: x (torch.Tensor): The input data. Returns: torch.Tensor: The output of the module. """ x = F.relu(self.fc1_ratio * self.fc1(x)) x = torch.sigmoid(self.fc2_ratio * self...
Define the computation performed at every call. Args: x (torch.Tensor): The input data. Returns: torch.Tensor: The output of the module.
_forward
python
open-mmlab/mmaction2
mmaction/models/localizers/bsn.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/localizers/bsn.py
Apache-2.0
def loss(self, batch_inputs, batch_data_samples, **kwargs): """Calculate losses from a batch of inputs and data samples. Args: batch_inputs (Tensor): Raw Inputs of the recognizer. These should usually be mean centered and std scaled. batch_data_samples (List[:obj...
Calculate losses from a batch of inputs and data samples. Args: batch_inputs (Tensor): Raw Inputs of the recognizer. These should usually be mean centered and std scaled. batch_data_samples (List[:obj:`ActionDataSample`]): The batch data samples. It usual...
loss
python
open-mmlab/mmaction2
mmaction/models/localizers/bsn.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/localizers/bsn.py
Apache-2.0
def predict(self, batch_inputs, batch_data_samples, **kwargs): """Define the computation performed at every call when testing.""" device = self.fc1.weight.device bsp_feature = torch.cat([ sample.gt_instances['bsp_feature'] for sample in batch_data_samples ]).to(device) ...
Define the computation performed at every call when testing.
predict
python
open-mmlab/mmaction2
mmaction/models/localizers/bsn.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/localizers/bsn.py
Apache-2.0
def forward(self, inputs, data_samples, mode, **kwargs): """The unified entry for a forward process in both training and test. The method should accept three modes: - ``tensor``: Forward the whole network and return tensor or tuple of tensor without any post-processing, same as a commo...
The unified entry for a forward process in both training and test. The method should accept three modes: - ``tensor``: Forward the whole network and return tensor or tuple of tensor without any post-processing, same as a common nn.Module. - ``predict``: Forward and return the predictio...
forward
python
open-mmlab/mmaction2
mmaction/models/localizers/bsn.py
https://github.com/open-mmlab/mmaction2/blob/master/mmaction/models/localizers/bsn.py
Apache-2.0