Hm, check if gray code won’t solve this problem; take n-digit gray codes and select 2^m regularly spaced elements as output space (using input as index)
In case that won’t work, I still feed that you need to seek a mathematical solution instead of “training”.