Answered step by step
Verified Expert Solution
Question
1 Approved Answer
is this implementation of DEF method correct? def dfp ( w _ 0 , B _ 0 , data, labels, pred _ f = prediction,
is this implementation of DEF method correct?
def dfpw B data, labels, predfprediction, gradfgradient, lossflogloss maxiter tol:
w w
Binv nplinalg.invB # We only compute the inverse at initialization
gradw gradflenw w data, labels
for i in rangemaxiter:
# Step :
p npdotBinv, gradw # Use npdot instead of npouter
# Step :
alpha wolfew p data, labels
# Step :
s alpha p
wnew w s
gradnew gradflenw wnew, data, labels
# Step :
if nplinalg.normgradnew gradw tol:
break
y gradnew gradw
gradw gradnew
sy npdots y
# Step DFP Update:
Bs npdotBinv, s
Binv Binv npouters s npdots y npouterBs Bs npdots Bs
# Step print:
predictions predfw data
loss lossfpredictions labels
printiter: i loss:", loss
w wnew
return w
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started