Capsule Networks as Generative Models