对VSCODE的显示进行调整,在debug阶段可查看tensor维度 import torch def custom_repr(self): return f'{{Tensor:{tuple(self.shape)}}} {original_repr(self)}' original_repr = torch.Tensor.__repr__ torch.Tensor.__repr__ = custom_repr 效果显示