GANExecutor

Inheritance Diagram

Inheritance diagram of ashpy.losses.gan.GANExecutor

class ashpy.losses.gan.GANExecutor(fn=None)[source]

Bases: ashpy.losses.executor.Executor, abc.ABC

Executor for GANs.

Implements the basic functions needed by the GAN losses.

Methods

call(context, **kwargs)

Execute the function, using the information provided by the context.

get_discriminator_inputs(context, …)

Return the discriminator inputs.

Attributes

fn

Return the Keras loss function to execute.

global_batch_size

Global batch size comprises the batch size for each cpu.

weight

Return the loss weight.

abstract call(context, **kwargs)[source]

Execute the function, using the information provided by the context.

Parameters

context (ashpy.contexts.Context) – The function execution Context.

Returns

tf.Tensor – Output Tensor.

static get_discriminator_inputs(context, fake_or_real, condition, training)[source]

Return the discriminator inputs. If needed it uses the encoder.

The current implementation uses the number of inputs to determine whether the discriminator is conditioned or not.

Parameters
  • context (ashpy.contexts.gan.GANContext) – Context for GAN models.

  • fake_or_real (tf.Tensor) – Discriminator input tensor, it can be fake (generated) or real.

  • condition (tf.Tensor) – Discriminator condition (it can also be generator noise).

  • training (bool) – whether is training phase or not

Return type

Union[Tensor, List[Tensor]]

Returns

The discriminator inputs.