TypeError: mul got incompatible shapes for broadcasting: (8, 2), (16, 2)

Receiving incomaptible shapes error when calling train_model(). Unit test on model architecture was passed with no errors before.

Mean() layer is created along axis = 1
Dense Layer has outputs 2

Is there a way to directly inspect where in tl.Serial() the shape mismatch is happening, i.e. which layers are causing trouble?

Also, shapes (8, 2), (16, 2) seem to indicate some issue related batch_size (=16) but we are not changing values for batch_size in the course of the assignment.

Any help is greatly appreciated!

Cheers
Ben

1 Like

Got it. Create mean_layer using keep_dims=True: tl.Mean(axis=1, keepdims=True)

2 Likes

No need for keepdims at the moment of writing; otherwise accuracy will not converge.

I’m facing the same error and, as @kos mentioned, using keepdims makes accuracy not converge. So, any hints of what can be happening here? :slight_smile:

1 Like

Did anyone on this thread solve this broadcasting shapes problem? From my reading of the responses, adding keepdims isn’t a complete solution.

1 Like