Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Getting this error when trying to run model not sure what is wrong pls help In [ ]: # Task 3 def forward_backward(X, Y, w,
Getting this error when trying to run "model" not sure what is wrong pls help
In [ ]: # Task 3 def forward_backward(X, Y, w, b): Implement the forward and backward passes for logistic regression Args: X -- data of size (64 * 64, number of examples) Y-- true label vector of size (1, number of examples) w weights, a numpy array of size (64 *64, 1) b -- bias, a scalar Returns: grads -- containing gradients, dw and db cost - cost for the current pass m = X. shape [1] Forward ## START TODO ### Znp.dot (w.T, X)+b A- sigmoid(Z) cost-1*((np.sum( (Y np.log (A))+((1-Y)*(np.log(1-A))), axis-1))/m) ## END TODO ### # Backward ## START TODO ### dw = np . dot ( X, (A-Y)T)/m db = np. sum((A-Y) , axis-1) /m ## END TODO ### assert (dw.shape .shape) assert (db.dtypefloat) costnp.squeeze (cost) assert (cost.shape)) return grads, cost In [ ]: # Task 3 def forward_backward(X, Y, w, b): Implement the forward and backward passes for logistic regression Args: X -- data of size (64 * 64, number of examples) Y-- true label vector of size (1, number of examples) w weights, a numpy array of size (64 *64, 1) b -- bias, a scalar Returns: grads -- containing gradients, dw and db cost - cost for the current pass m = X. shape [1] Forward ## START TODO ### Znp.dot (w.T, X)+b A- sigmoid(Z) cost-1*((np.sum( (Y np.log (A))+((1-Y)*(np.log(1-A))), axis-1))/m) ## END TODO ### # Backward ## START TODO ### dw = np . dot ( X, (A-Y)T)/m db = np. sum((A-Y) , axis-1) /m ## END TODO ### assert (dw.shape .shape) assert (db.dtypefloat) costnp.squeeze (cost) assert (cost.shape)) return grads, costStep 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