On the Generalization of Learned Structured Representations