I know a theory about how to do this.
- Here is a paper explaining it: https://www.researchgate.net/publication/215991433_Learning_Invariance_From_Transformation_Sequences
- Here is my lecture explaining it: Video Lecture of Kropff & Treves, 2008
I hope this helps