That looks like your model does not output the correct size… It could happen in many places, I’d recommend printing the shape of internal variables in the forward method of your network, so that you can pinpoint the exact location that introduces the error and debug that.
It would also help if you can share the code of your architecture! But it would be understandable if you can’t