model = dict(
type='Recognizer3D',
backbone=dict(
type='ResNet3dSlowOnly',
in_channels=17,
base_channels=32,
num_stages=3,
out_indices=(2, ),
stage_blocks=(4, 6, 3),
conv1_stride=(1, 1),
pool1_stride=(1, 1),
inflate=(0, 1, 1),
spatial_strides=(2, 2, 2),
temporal_strides=(1, 1, 1)),
cls_head=dict(
type='I3DHead',
in_channels=512,
num_classes=60,
dropout=0.5),
test_cfg=dict(average_clips='prob'))
type='ResNet3dSlowOnly',
定位到代码位置如下
pyskl/models/cnns/resnet3d_slowonly.py
# Copyright (c) OpenMMLab. All rights reserved.
from ..builder import BACKBONES
from .resnet3d import ResNet3d
@BACKBONES.register_module()
class ResNet3dSlowOnly(ResNet3d):
"""SlowOnly backbone based on ResNet3d.
Args:
conv1_kernel (tuple[int]): Kernel size of the first conv layer. Default: (1, 7, 7).
inflate (tuple[int]): Inflate Dims of each block. Default: (0, 0, 1, 1).
**kwargs (keyword arguments): Other keywords arguments for 'ResNet3d'.
"""
def __init__(self, conv1_kernel=(1, 7, 7), inflate=(0, 0, 1, 1), **kwargs):
super().__init__(conv1_kernel=conv1_kernel, inflate=inflate, **kwargs)
分析:直接第一个init函数里面的参数自定义好了就是(1, 7, 7)代入到第二个init函数里面的conv1_kernel=conv1_kernel等号右边这个conv1_kernel
也就是说子类里面只有这两个参数进行了改变,其它的参数都沿用使用父类的