ValueError: setting an array element with a sequence. - Error in python code for loss calculation

Hi I am trying to replicate the code written in the class but getting the unexpected error

for i in range(WW.shape[0]):
    for j in range(WW.shape[1]):
        Loss[i,j] = calculate_loss(X,Y, WW[i,j], BB[i,j])

ValueError: setting an array element with a sequence.

Please share the code for calculate_loss function

image

It worked, I have added dtype=object, but in the code written by professor the dtype=object is not mentioned

My code:
image

Professor’s code:
image

Thanks for he prompt reply

2 Likes