from mmcv.cnn import build_conv_layer
build_conv_layer函数会构建一个卷积层。
函数需要提供的参数有:
不传入cfg情况下,默认为构建nn.Conv2d,且卷积层参数均为默认。
返回的参数为:
from mmcv.cnn import build_conv_layer
cfg = dict(
type='Conv2d'
)
conv2d = build_conv_layer(cfg, in_channels=3, out_channels=16, kernel_size=3)
print(conv2d) # Conv2d(3, 16, kernel_size=(3, 3), stride=(1, 1))
cfg2 = dict(
type='Conv2d',
in_channels=3,
out_channels=16,
kernel_size=5
)
conv2d_2 = build_conv_layer(cfg2)
print(conv2d_2) # Conv2d(3, 16, kernel_size=(5, 5), stride=(1, 1))