# 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
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?