Learning Canonical Transformations