Learning invariant representations and applications to faceverification