SparseSequential¶
- class mmcv.ops.SparseSequential(*args, **kwargs)[源代码]¶
A sequential container. Modules will be added to it in the order they are passed in the constructor. Alternatively, an ordered dict of modules can also be passed in.
To make it easier to understand, given is a small example:
.. rubric:: 示例
>>> # using Sequential: >>> from mmcv.ops import SparseSequential >>> model = SparseSequential( SparseConv2d(1,20,5), nn.ReLU(), SparseConv2d(20,64,5), nn.ReLU() )
>>> # using Sequential with OrderedDict >>> model = SparseSequential(OrderedDict([ ('conv1', SparseConv2d(1,20,5)), ('relu1', nn.ReLU()), ('conv2', SparseConv2d(20,64,5)), ('relu2', nn.ReLU()) ]))
>>> # using Sequential with kwargs(python 3.6+) >>> model = SparseSequential( conv1=SparseConv2d(1,20,5), relu1=nn.ReLU(), conv2=SparseConv2d(20,64,5), relu2=nn.ReLU() )
- forward(input: torch.Tensor) → torch.Tensor[源代码]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
注解
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.