Neural Networks and Deep Learning – IV: Logistic Regression – Cost Calculation

Loss Function

This function calculates the difference between the output you have obtained and the y that should be.


Python Code of Loss Function

import numpy as np
def custom_loss(y, yhat):
    return -(y*np.log(yhat) - (1-y)*np.log(1-yhat)**2).mean()

Cost Function

The cost function is the average of the error function. We will find the w and b parameters that minimize the total cost.

Python Code of Cost Function

import numpy as np
def cost_func(Y,Yhat,m): 
return -1/m * np.sum(,np.log(Yhat)) +, np.log(1-Yhat)))

Leave a Reply

Your email address will not be published. Required fields are marked *