Error in train_model

Hi all,

I cannot get to run exercise 6 (train_model). All unit tests from exercise 1-5 have passed.
In exercise 6 I keep getting the following error (only last line):
TypeError: mul got incompatible shapes for broadcasting: (16, 2), (13, 2).

My labID is zliztxhr.

I really tried a lot and also searched this forum quite extensively, so I would be really thankful for your help! :slight_smile:

Claudia

Well your problem says that the shape of the matrices you are multiplying is not compatible so check where those matrices are created and trace down the problem.

Had the exact same problem. Kindly see how you are taking the mean of the layers and specify it if not already.
Cheers!

1 Like

Hi Claudia,

When doing matrix (dot) multiplication, the rule of thumb is the number of columns of the first matrix must be equal to the number of rows on the second matrix.

i.e. if A is (3 \times 4) matrix, it can only be dotted to a matrix that has the number of rows equal to 4, or that the dimension must be (4\times n) where n\in \mathbb{Z^+}.

Since I can’t see your code due to community guidelines, I can’t be completely certain of the problem you are facing but my guess, in this case, is for you to take the transpose of the second matrix in your dot product.

That was it!
I defined mean_layer = tl.Mean(axis=0), but it should be axis=1. That hadn’t been picked up in the respective unit test.
Thank you so, so much! I was going crazy with this assignment :wink:

1 Like