implemented training function for min_cg but it's taking forever to run. Need to teak the tolerance parameter or include some way to stop the training after exceeding a certain iteration