mmagic.models.utils.sampling_utils
¶
Module Contents¶
Functions¶
|
Sample noise with respect to the given num_batches, noise_size and |
|
Sample random label with respect to num_batches, num_classes and |
- mmagic.models.utils.sampling_utils.noise_sample_fn(noise: Union[torch.Tensor, Callable, None] = None, *, num_batches: int = 1, noise_size: Union[int, Sequence[int], None] = None, device: Optional[str] = None) torch.Tensor [source]¶
Sample noise with respect to the given num_batches, noise_size and device.
- Parameters
noise (torch.Tensor | callable | None) – You can directly give a batch of noise through a
torch.Tensor
or offer a callable function to sample a batch of noise data. Otherwise, theNone
indicates to use the default noise sampler. Defaults to None.num_batches (int, optional) – The number of batch size. Defaults to 1.
noise_size (Union[int, Sequence[int], None], optional) – The size of random noise. Defaults to None.
device (Optional[str], optional) – The target device of the random noise. Defaults to None.
- Returns
Sampled random noise.
- Return type
Tensor
- mmagic.models.utils.sampling_utils.label_sample_fn(label: Union[torch.Tensor, Callable, List[int], None] = None, *, num_batches: int = 1, num_classes: Optional[int] = None, device: Optional[str] = None) Union[torch.Tensor, None] [source]¶
Sample random label with respect to num_batches, num_classes and device.
- Parameters
label (Union[Tensor, Callable, List[int], None], optional) – You can directly give a batch of label through a
torch.Tensor
or offer a callable function to sample a batch of label data. Otherwise, theNone
indicates to use the default label sampler. Defaults to None.num_batches (int, optional) – The number of batch size. Defaults to 1.
num_classes (Optional[int], optional) – The number of classes. Defaults to None.
device (Optional[str], optional) – The target device of the label. Defaults to None.
- Returns
Sampled random label.
- Return type
Union[Tensor, None]