gan¶
GAN metrics.
Classes
The Discriminator loss value. |
|
Encoder Loss value. |
|
Generator and Encoder accuracy performance. |
|
Generator loss value. |
|
Inception Score Metric. |
-
class
ashpy.metrics.gan.DiscriminatorLoss(model_selection_operator=None, logdir='/home/docs/checkouts/readthedocs.org/user_builds/ashpy/checkouts/v0.1.3/docs/source/log')[source]¶ Bases:
ashpy.metrics.metric.MetricThe Discriminator loss value.
-
__init__(model_selection_operator=None, logdir='/home/docs/checkouts/readthedocs.org/user_builds/ashpy/checkouts/v0.1.3/docs/source/log')[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.Callablebehaving like anoperatoris 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.
- Return type
None
-
-
class
ashpy.metrics.gan.EncoderLoss(model_selection_operator=None, logdir='/home/docs/checkouts/readthedocs.org/user_builds/ashpy/checkouts/v0.1.3/docs/source/log')[source]¶ Bases:
ashpy.metrics.metric.MetricEncoder Loss value.
-
__init__(model_selection_operator=None, logdir='/home/docs/checkouts/readthedocs.org/user_builds/ashpy/checkouts/v0.1.3/docs/source/log')[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.Callablebehaving like anoperatoris 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.
- Return type
None
-
-
class
ashpy.metrics.gan.EncodingAccuracy(classifier, model_selection_operator=None, logdir='/home/docs/checkouts/readthedocs.org/user_builds/ashpy/checkouts/v0.1.3/docs/source/log')[source]¶ Bases:
ashpy.metrics.classifier.ClassifierMetricGenerator and Encoder accuracy performance.
Measure the Generator and Encoder performance together, by classifying: G(E(x)), y using a pre-trained classified (on the dataset of x).
-
__init__(classifier, model_selection_operator=None, logdir='/home/docs/checkouts/readthedocs.org/user_builds/ashpy/checkouts/v0.1.3/docs/source/log')[source]¶ Measure the Generator and Encoder performance together.
This is done by classifying: G(E(x)), y using a pre-trained classified (on the dataset of x).
- Parameters
classifier (
tf.keras.Model) – Keras Model to use as a Classifier to measure the accuracy. Generally assumed to be the Inception Model.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.Callablebehaving like anoperatoris 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.
- Return type
None
-
-
class
ashpy.metrics.gan.GeneratorLoss(model_selection_operator=None, logdir='/home/docs/checkouts/readthedocs.org/user_builds/ashpy/checkouts/v0.1.3/docs/source/log')[source]¶ Bases:
ashpy.metrics.metric.MetricGenerator loss value.
-
__init__(model_selection_operator=None, logdir='/home/docs/checkouts/readthedocs.org/user_builds/ashpy/checkouts/v0.1.3/docs/source/log')[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.Callablebehaving like anoperatoris 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.
-
-
class
ashpy.metrics.gan.InceptionScore(inception, model_selection_operator=<built-in function gt>, logdir='/home/docs/checkouts/readthedocs.org/user_builds/ashpy/checkouts/v0.1.3/docs/source/log')[source]¶ Bases:
ashpy.metrics.metric.MetricInception Score Metric.
This class is an implementation of the Inception Score technique for evaluating a GAN.
See Improved Techniques for Training GANs 1.
- 1
Improved Techniques for Training GANs https://arxiv.org/abs/1606.03498
-
__init__(inception, model_selection_operator=<built-in function gt>, logdir='/home/docs/checkouts/readthedocs.org/user_builds/ashpy/checkouts/v0.1.3/docs/source/log')[source]¶ Initialize the Metric.
- Parameters
inception (
tf.keras.Model) – Keras Inception model.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.Callablebehaving like anoperatoris 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.
-
static
get_or_train_inception(dataset, name, num_classes, epochs, fine_tuning=False, loss_fn=<tensorflow.python.keras.losses.SparseCategoricalCrossentropy object>, optimizer=<tensorflow.python.keras.optimizer_v2.adam.Adam object>, logdir='/home/docs/checkouts/readthedocs.org/user_builds/ashpy/checkouts/v0.1.3/docs/source/log')[source]¶ Restore or train (and save) the Inception model.
- Parameters
dataset (
tf.data.Dataset) – Dataset to re-train Inception Model on.name (str) – Name of this new Inception Model, used for saving it.
num_classes (int) – Number of classes to use for classification.
epochs (int) – Epochs to train the Inception model for.
fine_tuning (bool) – Controls wether the model will be fine-tuned or used as is.
loss_fn (
tf.keras.losses.Loss) – Keras Loss for the model.optimizer (
tf.keras.optimizers.Optimizer) – Keras optimizer for the model.logdir (str) – Path to the log dir, defaults to a log folder in the current directory.
- Return type
Model- Returns
tf.keras.Model– The Inception Model.
-
inception_score(images)[source]¶ Compute the Inception Score.
- Parameters
images (
listof [numpy.ndarray]) – A list of ndarray of generated images of 299x299 of size.- Return type
Tensor- Returns
tupleof (numpy.ndarray,numpy.ndarray) – Mean and STD.