[文档]@OPERATORS.register_module('random_selector')classRandomSelector(Selector):"""Selector to random select samples. """
[文档]def__init__(self,select_ratio:Optional[Annotated[float,Field(ge=0,le=1)]]=None,select_num:PositiveInt=None,*args,**kwargs):""" Initialization method. :param select_ratio: The ratio to select. When both select_ratio and select_num are set, the value corresponding to the smaller number of samples will be applied. :param select_num: The number of samples to select. When both select_ratio and select_num are set, the value corresponding to the smaller number of samples will be applied. :param args: extra args :param kwargs: extra args """super().__init__(*args,**kwargs)self.select_ratio=select_ratioself.select_num=select_num