# Does input to GAN discriminator have to be differentiable output of generator?

I understand the basic of how GANs work with the min-max game, etc. However, I don't fully understand how the error backpropagates to the generator.

Let's say I have an input vector $x$ to the generator. The generator computes some output $G(x)$. If I perform some non-differentiable function on $G(x)$, call it $h(G(x))$, can this be the input to my discriminator?

For example, maybe $h(z)$ is a clustering function, that clusters elements of $z$ into groups. My ground truth sample for the discriminator might be existing clusters $\hat{h}(x)$. Could my generator produce $G(x)$, but my discriminator see as input $\left(h\left(G(x)\right), \hat{h}(x)\right)$?

If so, how does the backpropagation work, given that $h(z)$ is not differentiable?

If $h$ is nondifferentiable, then using GANs is not straightforward. One example of where you might want to do this is sentence generation, where an LSTM models a (conditional) probability distribution across possible sentences and the function $h$ samples one particular sentence from the distribution. A discrete clustering would also be nondifferentiable. In this case, it is necessary to use reinforcement learning techniques.
In the proposed case, you would not be able to perform the optimization of the generator loss, as the non-differentiable operation $h$ prevents from using backpropagation in the Generator's weights.
However, why would you have such a setup instead of a normal $D(G(x))$? If you have cluster labels, you can use conditional GANs by supplying those labels to both Generator and Discriminator.