forward propogation and cost function calculation implemented.