Invariant representation learning via functions in reproducing kernel hilbert spaces