# GANs - G: multiple outputs / D: Single Loss

**URL:** <https://discuss.pytorch.org/t/gans-g-multiple-outputs-d-single-loss/48019>\
**Category:** autograd\
**Created:** [June 15, 2019, 12:46pm UTC](https://discuss.pytorch.org/t/gans-g-multiple-outputs-d-single-loss/48019 "2019-06-15T12:46:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Timos\_Korres](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/timos_korres/32/13109_2.png) [@Timos\_Korres](https://discuss.pytorch.org/u/Timos_Korres)\
**Post date:** [June 15, 2019, 12:46pm UTC](https://discuss.pytorch.org/t/gans-g-multiple-outputs-d-single-loss/48019/1 "2019-06-15T12:46:13Z")

</div>

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
