ultralytics
ultralytics copied to clipboard
Sizes of tensors must match except in dimension 1. Expected size 46 but got size 45 for tensor number 1 in the list
Search before asking
- [X] I have searched the Ultralytics YOLO issues and discussions and found no similar questions.
Question
When using a custom yaml file to add P6 and P7 headers, and enabling multi-scale training, and using DDP training, an error message "Sizes of tensors must match except in dimension 1" appears Expected size 46 but got size 45 for tensor number 1 in the list。 The reason may be that the model did not copy the stride attribute of the model when copying between gpu devices, resulting in gs=max (int (self. model. stride. max() if hasattr (self. model, "stride") else 32) being fixed to 32, which actually requires gs=64 or 128. A simple solution is to manually add self. stride=64 on line 62 of the model/yolo/detect/train. py - DetectionTrainer preprocess_match
Additional
No response