argmin implementation for learning