Unable to run code in optional lab

Hi there,

I am unable to run the code in the optional lab—it is always giving me some or the other error.

Could you please help with that ?
Week 2

Thanks in advance

Dear @vikassharma58,

  1. The first line of your code you need to use, for example, np.dot(x[I], w) instead of just using the multiplication symbol in python.
    Python is probably trying to broadcast the multiplication instead of calculating a correct matrix multiplication (which is a generalization of the dot product).
    So, for the first line take a look at your matrix dimensions see if the multiplication is a matrix multiplication and not the usual multiplication with broadcasting which is what Python would do.
    For matrix multiplication you need to use numpy’s np.matmult or np.dot depending on your dimensions.

  2. The second line of your code does not seem correct either remember that X is a matrix a two dimensional array and not a vector a one dimensional array.

  1. The third line is also wrong since the first is wrong.

  2. Why do you use the break in HTML in line? Erase it because the error you get there does not tell you anything about the relevant code for the optional exercise.

I hope you find these tips helpful.

That looks like an html or markdown tag, not python code.

I think that you may have accidentally inserted a new cell (the one marked as [10].
Try deleting it.

@laacdm, on your first three numbered points, those aren’t in the cell that is throwing the error.

Tip: In the optional labs, students don’t have to add any code. All that code is provided with the notebook.

Yes @TMosh you are right about my first three points.

However, the student question seems quite vague. The screenshot with code presented by the student is quite different from the one that appears in the lab (at least my version) and the the extra code cell with the HTML tag for break seemed to be a very trivial error that I decided to mention other things that appear weird from the screenshot that was provided in order for the student to be aware of other things that might not appear right later.

1 Like

Thank you! I appreciate your quick support!

Thanks a lot!