MaliGAN Discriminator

class textbox.module.Discriminator.MaliGANDiscriminator.MaliGANDiscriminator(config, dataset)[source]

Bases: UnconditionalGenerator

MaliGANDiscriminator is LSTMs.

calculate_loss(real_data, fake_data)[source]

Calculate the loss for real data and fake data. The discriminator is trained with the standard objective that GAN employs.

Parameters
  • real_data (torch.Tensor) – The realistic sentence data, shape: [batch_size, max_seq_len].

  • fake_data (torch.Tensor) – The generated sentence data, shape: [batch_size, max_seq_len].

Returns

The calculated loss of real data and fake data, shape: [].

Return type

torch.Tensor

forward(data)[source]

Calculate the probability that the data is realistic.

Parameters

data (torch.Tensor) – The sentence data, shape: [batch_size, max_seq_len].

Returns

The probability that each sentence is realistic, shape: [batch_size].

Return type

torch.Tensor

training: bool