Mat1 and mat2 shapes cannot be multiplied - Batch VS No batch

The problem:
If I try to match the 2 matrices in either case (1X or 64X (batch)), it will fail in the other

Case 1: 1X: mat1 and mat2 shapes cannot be multiplied (64x512 and 32x256)
Case 2: 64X: mat1 and mat2 shapes cannot be multiplied (64x32 and 512x256)

By trying to match, I mean changing the size of layer4, the deeply connected layer which follows the flattened layer, where the error triggers in both cases

Extra info:
Input.size is (64 batches,) 3 channels, 16 rows, 8 columns

What am I missing?

Hi @Dev2150
This is way too short for us to help you.
What are you trying to do? What does and doesn’t work exactly? Where does the error occur, what’s the size of the input and the config of the layer etc.
Don’t hesitate to be prolific, better to give too much info than not enough

1 Like

Sorry I saw that you edited your question but I still can’t make sense out of it.
What’s case 1 and 2? What X in 1X? The batch size? What do you mean by no batch? A batch of 1 or no batch dimensions at all?

What I understand is that you are flattening the tensor from dim 0 to dim 1 in both cases, but in the 1X case it seems that you don’t have a first dimension. Maybe that should only be applied when you have a batch?

What’s layer4 exactly? What are you trying to do with it? What size do you expect for the input tensor? What do you want to do with the flatten layer? What do you mean by “if I try to match the two matrices”? What are you highlighting in your case 1 and case 2?

If you could re-write the question in more details it would be great.

1 Like

I’ve tried reposting with more information but it was flagged and taken down.
What I understand is that you are flattening the tensor from dim 0 to dim 1 in both cases, but in the 1X case it seems that you don’t have a first dimension. Maybe that should only be applied when you have a batch?
ooooooooooh… this must be it… i must always provide the state with the same dimensions, even if one of them has size 1. Thank you

Edited post:

The problem:
If I try to match the 2 matrices in either case (64X (batch) or 1X), it will fail in the other

Case 1:
mat1 and mat2 shapes cannot be multiplied (64x512 and 32x256)
state tensor size: 64x3x16x8
Stack trace: Training Loop → agent.learn () → Forward()

All taken decisions are random

Case 2:
mat1 and mat2 shapes cannot be multiplied (64x32 and 512x256)
state tensor size: 3x16x8
Stack trace: Training Loop → agent.choose_action() → Forward()

This error happens after the other one, when it has to take (the first?) decision that is not random

By trying to match, I mean changing the size of layer4, the deeply connected layer which follows the flattened layer, where the error triggers in both cases

My interpretation: In case 2, layer4 expects a way smaller dataset because it’s not a batch

Extra info:
Input.size is (64 batches,) 3 channels, 16 rows, 8 columns

What am I missing?