GANs - G: multiple outputs / D: Single Loss

I’m trying to train a generator to learn how to output a set of k items [x1,x2,x3] out of K total items. Each item is represented as a fully connected layer with size equal to K (Choosing one of K items). The discriminator must recognize whether these specific items are real or not.

The number of output items is variable, is a hyperparameter So, I have two questions:

  1. How can I return variable number of outputs (hyperparameter) from the generator in order to compute the gradient separately? -> My solution is to return them as a big tuple. Is this enough to compute the gradients correctly?

  2. The loss is computed for the whole set of items and not for each one of them. That means I only have one loss function. How can compute the gradients for each one of them?

Any suggestions are also welcome