Getting output of intermediate layers for a test input

This answer from the forums provides a simple implementation of a forward hook to obtain the output of a particular model layer.