SlicedWassersteinDistance¶
Inheritance Diagram
-
class
ashpy.metrics.sliced_wasserstein_metric.
SlicedWassersteinDistance
(name='SWD', model_selection_operator=<built-in function lt>, logdir=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/ashpy/checkouts/master/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]¶ Bases:
ashpy.metrics.metric.Metric
Sliced Wasserstein Distance.
Used as metric in Progressive Growing of GANs [1].
[1] Progressive Growing of GANs https://arxiv.org/abs/1710.10196 Methods
__init__
([name, model_selection_operator, …])Initialize the Metric. log
(step)Log the SWD mean and each sub-metric. model_selection
(checkpoint, global_step)Perform model selection for each sub-metric. reset_states
()Reset the state of the metric and the state of each child metric. update_state
(context)Update the internal state of the metric, using the information from the context object. Attributes
best_folder
Retrieve the folder used to save the best model when doing model selection. best_model_sel_file
Retrieve the path to JSON file containing the measured performance of the best model. logdir
Retrieve the log directory. metric
Retrieve the tf.keras.metrics.Metric
object.model_selection_operator
Retrieve the operator used for model selection. name
Retrieve the metric name. sanitized_name
all / are _. -
__init__
(name='SWD', model_selection_operator=<built-in function lt>, logdir=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/ashpy/checkouts/master/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: - name (str) – Name of the metric.
- 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 anoperator
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
-
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
-