Added functionality to save weights learned