Skip to content

The descendGradient function code has bug in ex1. The parameters in theta are not being updated simultaneously. #12

@gautam-bmdi

Description

@gautam-bmdi

the line
tmptheta = theta
should be updated to
tmptheta = np.copy(theta) // create a deep copy of theta instead of a new reference!

Otherwise the below statement will update theta also while the tmptheta is being updated (as both are references to same object!). theta should NOT change during an iteration of gradient descent!
tmptheta[j] = theta[j] - (alpha/m)*np.sum((h(theta,X) - y)*np.array(X[:,j]).reshape(m,1))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions