sliced_wasserstein_metric¶

Sliced Wasserstein Distance metric.

Classes

 SingleSWD SlicedWassersteinDistance for a certain level of the pyramid. SlicedWassersteinDistance Sliced Wasserstein Distance.
class ashpy.metrics.sliced_wasserstein_metric.SingleSWD(model_selection_operator=<built-in function lt>, logdir='/home/docs/checkouts/readthedocs.org/user_builds/ashpy/checkouts/v0.2.0/docs/source/log', level_of_pyramid=0, real_or_fake='fake')[source]

SlicedWassersteinDistance for a certain level of the pyramid.

__init__(model_selection_operator=<built-in function lt>, logdir='/home/docs/checkouts/readthedocs.org/user_builds/ashpy/checkouts/v0.2.0/docs/source/log', level_of_pyramid=0, real_or_fake='fake')[source]

Initialize the Metric.

Parameters
• model_selection_operator (typing.Callable) –

The operation that will be used when model_selection is triggered to compare the metrics, used by the update_state. Any typing.Callable behaving like an operator is accepted.

Note

Model selection is done ONLY if an operator is specified here.

• logdir (str) – Path to the log dir, defaults to a log folder in the current directory.

• level_of_pyramid (int) – Level of the pyramid related to this metric.

• real_or_fake (str) – string identifying this metric (real or fake distance).

Return type

None

update_state(context, score)[source]

Update the internal state of the metric, using the information from the context object.

Parameters

context (ashpy.contexts.gan.GANContext) – An AshPy Context Object that carries all the information the Metric needs.

Return type

None

class ashpy.metrics.sliced_wasserstein_metric.SlicedWassersteinDistance(model_selection_operator=<built-in function lt>, logdir='/home/docs/checkouts/readthedocs.org/user_builds/ashpy/checkouts/v0.2.0/docs/source/log', resolution=128, resolution_min=16, patches_per_image=64, patch_size=7, random_sampling_count=1, random_projection_dim=147, use_svd=False)[source]

Sliced Wasserstein Distance.

Used as metric in Progressive Growing of GANs 1.

1

Progressive Growing of GANs https://arxiv.org/abs/1710.10196

__init__(model_selection_operator=<built-in function lt>, logdir='/home/docs/checkouts/readthedocs.org/user_builds/ashpy/checkouts/v0.2.0/docs/source/log', resolution=128, resolution_min=16, patches_per_image=64, patch_size=7, random_sampling_count=1, random_projection_dim=147, use_svd=False)[source]

Initialize the Metric.

Parameters
• model_selection_operator (typing.Callable) –

The operation that will be used when model_selection is triggered to compare the metrics, used by the update_state. Any typing.Callable behaving like an operator is accepted.

Note

Model selection is done ONLY if an operator is specified here.

• logdir (str) – Path to the log dir, defaults to a log folder in the current directory.

• resolution (int) – Image Resolution, defaults to 128

• resolution_min (int) – Min Resolution achieved by the metric

• patches_per_image (int) – Number of patches to extract per image per Laplacian level.

• patch_size (int) – Width of a square patch.

• random_sampling_count (int) – Number of random projections to average.

• random_projection_dim (int) – Dimension of the random projection space.

• use_svd (bool) – experimental method to compute a more accurate distance.

Return type

None

log(step)[source]

Log the SWD mean and each sub-metric.

model_selection(checkpoint, global_step)[source]

Perform model selection for each sub-metric.

Return type

None

reset_states()[source]

Reset the state of the metric and the state of each child metric.

Return type

None

update_state(context)[source]

Update the internal state of the metric, using the information from the context object.

Parameters

context (ashpy.contexts.gan.GANContext) – An AshPy Context Object that carries all the information the Metric needs.

Return type

None