Which criterion are you using and could you post the code, which yields the error as well as the output and target shapes?
The error message doesn’t match the provided target shape, so we would need to check, if some processing is done additionally.