I cannot fully track it but it’s a simple mistake about the amount of features. I see you are applying a max pool over some features l, therefore that tensor should be 4 dimensional, of size BxCx1x1 then you are squeezing it and getting a 2d tensor. So probably you have a missmatching. Just check the outgoing size of those features