Train a binary logistic regression classifier using gradient descent. Implement the training loop and return the learned parameters (w, b).
Model:
p=σ(Xw+b)=1+e−(Xw+b)1Loss (Binary Cross-Entropy):
L=−N1i=1∑N[yilogpi+(1−yi)log(1−pi)]_sigmoid(z): numerically stable sigmoid activationInput: X=[[0],[1],[2],[3]], y=[0,0,1,1], lr=0.1, steps=500
Expected: Accuracy ≥ 95%
Compute gradients:∇w=XT(p−y)/N and ∇b=mean(p−y).
Update parameters:w←w−lr⋅∇w andb←b−lr⋅∇b. Repeat the steps.
Sign in to take notes on this problem
Accepts: array
Accepts: array
Accepts: number
Accepts: number
Train a binary logistic regression classifier using gradient descent. Implement the training loop and return the learned parameters (w, b).
Model:
p=σ(Xw+b)=1+e−(Xw+b)1Loss (Binary Cross-Entropy):
L=−N1i=1∑N[yilogpi+(1−yi)log(1−pi)]_sigmoid(z): numerically stable sigmoid activationInput: X=[[0],[1],[2],[3]], y=[0,0,1,1], lr=0.1, steps=500
Expected: Accuracy ≥ 95%
Compute gradients:∇w=XT(p−y)/N and ∇b=mean(p−y).
Update parameters:w←w−lr⋅∇w andb←b−lr⋅∇b. Repeat the steps.
Sign in to take notes on this problem
Accepts: array
Accepts: array
Accepts: number
Accepts: number