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?
 A: 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. 
For example, the popular REINFORCE algorithm has been used to train GANs for the sentence generation task. See https://arxiv.org/abs/1609.05473.
A: You can use backpropagation with non-differentiable operations, but the gradients won't propagate through them and hence you won't be able to train weights that are before those operations. Sometimes this is a problem, sometimes it is not.
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.
P.S.: one option for having the clustering in your GAN setup would be to implement a differentiable clustering approach by leveraging internal representation separation (see this paper)
