Improving Photometric Redshifts by Training Complementary Features of Galaxy Templates Using Machine Learning