Shapes (2, 4) and (2, 6) are incompatible


I could not solve Exercise 6. I had ran the following code

{moderator edit - solution code removed}

I got the following error
Shapes (2, 4) and (2, 6) are incompatible

I have gone through most of the posts discussing the issue but nothing seems to work for me. Urgently need help.


Hi @mdrafat.siddiqui,

Welcome to the DLS forums!

It seems like labels has the wrong dimensions. Could it be that your one_hot implementation isn’t correct? The ‘train_signs’ dataset has 6 labels:

From " Basic Optimization with GradientTape"

The dataset that you’ll be using during this assignment is a subset of the sign language digits. It contains six different classes representing the digits from 0 to 5.

Double check the correctness of the one_hot implementation.

Hope that helps!

1 Like

Hi, @mdrafat.siddiqui.

Did you pass the assignment?

The only problem I saw was a hard-coded value in one_hot_matrix, as @neurogeek suspected.