Just trying to run the week 1 optional lab code of cost function in a jupyter notebook where this error pops out “list” object has no shape attribute.
AttributeError Traceback (most recent call last)
Cell In[52], line 2
1 plt.close(‘all’)
----> 2 fig, ax, dyn_items = plt_stationary(x_train, y_train)
3 updater = plt_update_onclick(fig, ax, x_train, y_train, dyn_items)
File ~\OneDrive\Desktop\Jupyter\lab_ml\lab_utils_uni.py:124, in plt_stationary(x_train, y_train)
122 for i in range(tmp_w.shape[0]):
123 for j in range(tmp_w.shape[1]):
→ 124 z[i,j] = compute_cost(x_train, y_train, tmp_w[i][j], tmp_b[i][j] )
125 if z[i,j] == 0: z[i,j] = 1e-6
127 w0=200;b=-100 #initial point
File ~\OneDrive\Desktop\Jupyter\lab_ml\lab_utils_common.py:79, in compute_cost(X, y, w, b)
68 def compute_cost(X, y, w, b):
69 “”"
70 compute cost
71 Args:
(…)
77 cost (scalar) : cost
78 “”"
—> 79 m = X.shape[0]
80 cost = 0.0
81 for i in range(m):
AttributeError: ‘list’ object has no attribute ‘shape’
please help asap