C2W4_Assignment error: Node: 'sequential_11/dense_22/MatMul' Matrix size-incompatible: In[0]: [32,1600], In[1]: [82944,512] [[{{node sequential_11/dense_22/MatMul}}]] [Op:__inference_train_function_7597]

Hi, I have this issue

[snippet removed by mentor]

======= note =======

[snippet removed by mentor]

Please click my name and message your notebook as an attachment.

To make an ImageDataGenerator support one-hot encoding of labels, use the class_mode parameter instead of doing it manually.

That said, there’s no need for you to do this since tensorflow supports a loss function that’ll account for integer encoded labels. Please refer the losses page to figure that out.

When I add class_mode, I received below error

Sorry for the confusion. I meant that the class has a function that supports class_mode. For the assignment, see methods like flow_from_dataframe method that supports this argument.

That said, as mentioned in the previous reply, you don’t have to use this parameter since leaving the labels integer encoded is okay as long as you pick the correct loss function.

Here’s another hint: Please refer ungraded labs from course 1 if you have trouble locating the correct loss function.

1 Like

I was able to fix the issue by looking into the loss functions that accept multi class for integers.
Also looking at the model inputs/outputs, if you do a model.summary() you’ll see which layer has the issue, the matmul issue relates to algebraic problems with matrix multiplications between layers, adjust the shapes by changing the filters and the input shape and you’ll have success.
let me know if you have any question

1 Like