Code:

```
def calc_loss(X,Y,w_est,b_est):
loss = 0
for x,y in zip(X,Y):
loss += (y - sigmoid(X,w_est,b_est))**2
return loss
W = np.linspace(-1,1,100)
B = np.linspace(-1,1,100)
WW,BB = np.meshgrid(W,B)
loss =np.zeros(WW.shape)
for i in range (WW.shape[0]):
for j in range (WW.shape[1]):
loss[i,j ] = calc_loss(X, Y, WW[i,j], BB[i,j]
```

ValueError Traceback (most recent call last)

in

1 for i in range (WW.shape[0]):

2 for j in range (WW.shape[1]):

----> 3 loss[i,j ] = calc_loss(X, Y, WW[i,j], BB[i,j])

*ValueError: setting an array element with a sequence.*

I tried fixing this with one of the earlier suggested ways :

```
loss =np.zeros(WW.shape, dtype='object')
for i in range (WW.shape[0]):
for j in range (WW.shape[1]):
loss[i,j ] = calc_loss(X, Y, WW[i,j], BB[i,j])
from mpl_toolkits import mplot3d
fig = plt.figure()
ax = plt.axes(projection='3d')
ax.plot_surface(WW,BB,loss,cmap='YlOrRd')
ax.set_xlabel('w_est')
ax.set_ylabel('b_est')
ax.set_zlabel('Loss')
```

But this gave another error :

ValueError Traceback (most recent call last)

in

2 fig = plt.figure()

3 ax = plt.axes(projection=‘3d’)

----> 4

ax.plot_surface(WW,BB,loss,cmap=‘YlOrRd’)

5 ax.set_xlabel(‘w_est’)

6 ax.set_ylabel(‘b_est’)

*ValueError: Collections can only map rank 1 arrays*``

Can anyone please suggest some way of fixing either of these errors to plot the Loss Function.