Shortcuts

mmedit.models.utils.sampling_utils

Module Contents

Functions

noise_sample_fn(→ torch.Tensor)

Sample noise with respect to the given num_batches, noise_size and

label_sample_fn(→ Union[torch.Tensor, None])

Sample random label with respect to num_batches, num_classes and

mmedit.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, the None 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

mmedit.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, the None 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]

Read the Docs v: latest
Versions
master
latest
stable
zyh-re-docs
zyh-doc-notfound-extend
zyh-api-rendering
Downloads
pdf
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.