title: Using the output of intermediate layers in a loss function in TF2
body: <p>I'm trying to replicate the training of OpenPose in Tensorflow 2 as part of my TF2 learning, but to be able to do this I need to use the output of the S, L intermediate layers in my loss function.</p>
  <p>I've tried using the functional API but I can't seem to get the output from the S/L layers to be able to use them in a loss function as required. I can see how this might be possible with subclassing but that would add complexity and not as ideal for debugging. Debugging and ease of use would probably be a massive plus at this stage in my learnings.</p>
  <p>Is there any way I can do this type of model with the functional API or sequential model?</p>
  <p><a href="https://i.stack.imgur.com/DRAEn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DRAEn.png" alt="enter image description here" /></a></p>