W4_A1_L_layer_Model_value error

Dear all,

I got an error regarding the programming assignment: Deep NN-Application, where we should build a L-layer Neural Network(NN).
After running this line:
parameters, costs = L_layer_model(train_x, train_y, layer_dims, num_iterations = 1, print_cost = False)

I get the following error:

ValueError: shapes (5,7) and (5,209) not aligned: 7 (dim 1) != 5 (dim 0)

I notice that the error comes from the function L_model_forward(X, parameters):

{moderator edit - solution code removed}

In the above function, when the AL wants to be computed from the A_prev, it gives the AL with wrong dimensions, which causes the error.

I was wondering if you can kindly help me to fix the error.

Thank you

Behnam

Try printing the value of l after you fall out of the for loop.

One other important point to make: if you are talking about the second assignment in Week 4, you are not supposed to “hand copy” your functions over from the first assignment. They provide them for you in an import file.

Hello,

Thank you for your reply. I printed the index l. It gives l=1.

I also check the shape of W, A_prev and A. The shapes are (7,12288), (12288,209) and (7,209), respectively. As you can see the shapes of A_prev and W are consistent. I do not really know why python complains about the dot products of A and W. As a result of that the AL cannot be computed.

Thank you for your help in advance,
Behnam

But the point is you need the value to be 2, right? What are the shapes of the W1 and W2? W1 is 5 x 7 and W2 is 1 x 5, right? So you are ending up with W1, when you want W2, which is why it throws.

But if you had used the given L_model_forward code instead of importing your own, this would not have been a problem, as I also pointed out in my previous reply. And if your code looked that way in the previous assignment, it would have failed there also, which is a little puzzling. That almost suggests that you rewrote it from scratch here.

Thank you. My code worked. Looks like the error was related to the for loop index.

Hello,

I have question regrading the assignment TensorFlow course 1 week4. In the last part of the assignment, where we want to train the model using catVSdog data, I have an error:

Part of the code is here:

{moderator edit - solution code removed}

The error is:
AttributeError: ‘str’ object has no attribute ‘base_dtype’

Any comments would be appreciated.

Thank you

A couple of points:

It doesn’t make sense to tack this question onto this existing thread. It’s about a completely different course, right?

Also I’m not a mentor for any of the TF Specializations, so I’m not the right person to help anyway.

Also note that we aren’t allowed to just post our solution code and ask someone else to fix it for you. The right thing to do is just post the full exception trace. We can’t tell anything from the error message, if we can’t even see the line that generated the exception.

So I will edit this post to remove the source code. The next step would be for you to create a new thread in the appropriate TF specialization topic and just show the full exception trace, not the source code please.

Kindly refrain from posting any codes in future as one should know it is against community guidelines as Paul mentioned to you.

Please make new post selecting the appropriate Specialisation, Course, Weeks’ and assignment name with the screenshot of your attribute error and explanation in the TF course specialisation.

You can also try to search for the same attribute error

by clicking on search tool on top where your profile is shown with this message
AttributeError: ‘str’ object has no attribute ‘base_dtype’

which will give you similar post threads if other learners have come across similar issue and how they have resolved the issue.

If not able to find or understand, you can always post your query with the appropriate method of posting a query and refrain from posting any codes.

Regards
DP