- class mmpretrain.models.classifiers.BaseClassifier(init_cfg=None, data_preprocessor=None)¶
Base class for classifiers.
An extra data pre-processing module, which processes data from dataloader to the format accepted by
Extract features from the input tensor with shape (N, C, …).
The sub-classes are recommended to implement this method to extract features from backbone and neck.
inputs (Tensor) – A batch of inputs. The shape of it should be
(num_samples, num_channels, *img_shape).
- extract_feats(multi_inputs, **kwargs)¶
Extract features from a sequence of input tensor.
- abstract forward(inputs, data_samples=None, mode='tensor')¶
The unified entry for a forward process in both training and test.
The method should accept three modes: “tensor”, “predict” and “loss”:
“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 predictions, which are fully processed to a list of
“loss”: Forward and return a dict of losses according to the given inputs and data samples.
Note that this method doesn’t handle neither back propagation nor optimizer updating, which are done in the
The return type depends on
mode="tensor", return a tensor or a tuple of tensor.
mode="predict", return a list of
mode="loss", return a dict of tensor.
- property with_head¶
Whether the classifier has a head.
- property with_neck¶
Whether the classifier has a neck.