title: Keras: Manually backprop from Discriminator to Generator
body: <p>I have a model that is essentially an Auxiliary Conditional GAN; the first part of the model is the Generator, the last part is the Discriminator.  The Discriminator makes multiclass (k=10) predictions.</p>
  
  <p>Following the work of <a href="http://arxiv.org/abs/1912.07768" rel="nofollow noreferrer">http://arxiv.org/abs/1912.07768</a> (pp3 for a helpful diagram, but note I ignore network structure modifications for the purposes of this question) I train the entire model for T=32 iterations by generating synthetic input and class labels (The 'inner loop').  I can predict on real data and labels using just the Discriminator(Learner) to get losses.  However I need to back-propagate the Discriminator's error all the way back through the inner loop to the Generator.</p>
  
  <p>How can I achieve this with Keras?  Is it possible to do loop unrolling in Keras?  How can I provide an arbitrary loss and backprop this down the unrolled layers?</p>
  
  <p>Update: There's now one implementation, in PyTorch, which uses Facebooks 'Higher' library. This appears to mean that the updates made during the inner loop must be 'unwrapped' in order for the final meta-loss to be applied throughout the entire network. Is there a Keras way of achieving this? <a href="https://github.com/GoodAI/GTN" rel="nofollow noreferrer">https://github.com/GoodAI/GTN</a></p>