Dear Team,
I am getting a ValueError : shapes (1,4) and (2,3) not aligned: 4 (dim 1) != 2 (dim 0).

I have tried to change optimize function because its always taking same values? Is it right to change that function or what to do? I am completely stuck in this. Before this, my all tests were passed…

Any kind of help is highly appreciated!! Thank you in advance…

It might be more helpful if you actually showed us the exception trace that you are getting.

Note that in propagate, the formula is this:

Z = w^T \cdot X + b

If that’s the line that’s throwing, then the question would be why your w weight vector is the wrong length. Where is that length determined? Are you testing model or optimize here? As above, more context would be helpful.

There are also some dot products in the back propagation calculations, but you don’t give us any clue where the error is being thrown.

Thank you for your kind help. Error is showing while running model_test(model) and this is the error

ValueError Traceback (most recent call last)
in
----> 1 model_test(model)

~/work/release/W2A2/public_tests.py in model_test(target)
111 y_test = np.array([1, 0, 1, 1, 0, 1])
112
→ 113 d = target(X, Y, x_test, y_test, num_iterations=50, learning_rate=1e-4)
114
115 assert type(d[‘costs’]) == list, f"Wrong type for d[‘costs’]. {type(d[‘costs’])} != list"
.
.
.
.
.

<array_function internals> in dot(*args, **kwargs)

ValueError: shapes (1,4) and (2,3) not aligned: 4 (dim 1) != 2 (dim 0)

There are more lines in between but that is the part of my code. Because of the honor code policy I haven’t paste those lines here. But in my opinion, cost calculation error is there in the propagate function. But while running propagate it is showing ohk that time…

In that test case, the input value for X_train has shape 4 x 3 and X_test has shape 4 x 6. So where did you get something that has the shape 2 x 3 for X? My guess is that you are probably referencing a global variable like X in your model code instead of X_train.

Thank you for replying me back. I am using X_train only in the model not X as it is the global variable and then also I am getting similar error. I don’t know where I am going wrong but all the above test cases are passed only this modeltest is creating issue…

After the notebook has been updated, now my propagate function is also showing error. It was previously running fine but now showing this type of error

Yes, this was a bug introduced in the assignment yesterday. It has just been fixed by the course staff about an hour ago (1630 7/24 UTC). Please update your notebook to the latest and then copy/paste over your solutions. Here’s another parallel thread with more discussion of this.

hi @paulinpaloalto … Thank you for replying me back. I have tried to complete my DLS week 2 course 1 assignment today, but now also the error has not been fixed in my notebook. It is showing similar error. All the previous tasks are pass but model function is not running till now also…
please help me out… the deadline for submission of the assignment is near… Please help me out…

Please don’t worry about the deadlines: they are fake in the sense that there is no penalty for missing them.

But in order to help you, you need to give us more information than just saying “my model function doesn’t pass”. What is the actual output you get from the test cases? Please realize that no-one else can see your notebooks. Also I’m travelling and my Internet connectivity is a little spotty, so I can’t guarantee a quick response.

I had similar issue
Did you check the initialization dimensions?
w, b =initialize_with_zeros(dim)
here you should use X_train too.
Hope this will help fixing your bug