HyperSIGMA icon indicating copy to clipboard operation
HyperSIGMA copied to clipboard

代码版本号

Open jqsun98 opened this issue 11 months ago • 3 comments

您好,可以提供一下模型在训练和finetune时候不同package的版本号吗?我在复现Spatial ViT for Indian Pines Segmentation代码的时候遇到了如下报错:

TypeError: save_for_backward can only save variables, but argument 1 is of type int

非常感谢!

jqsun98 avatar May 28 '25 03:05 jqsun98

请问您可以提供具体的报错位置嘛,以及您需要哪个package的版本号

jinyaoWHU avatar May 28 '25 11:05 jinyaoWHU

具体的报错位置如下: Traceback (most recent call last): File "F:\SCV\HyperSIGMA-main\HyperSIGMA-main\ImageClassification\demo seg Indian.py", line 185, in batch_pred = model(netinput) File "H:\Anaconda\envs\hyperspectral\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl result = self.forward(*input, **kwargs) File "F:\SCV\HyperSIGMA-main\HyperSIGMA-main\ImageClassification\model\SpatViT_seg.py", line 684, in forward feture = self.forward_features(x, self.patch_size) File "F:\SCV\HyperSIGMA-main\HyperSIGMA-main\ImageClassification\model\SpatViT_seg.py", line 668, in forward_features x = checkpoint.checkpoint(blk, x, Hp, Wp, deform_inputs) File "H:\Anaconda\envs\hyperspectral\lib\site-packages\torch\utils\checkpoint.py", line 177, in checkpoint return CheckpointFunction.apply(function, preserve, *args) TypeError: save_for_backward can only save variables, but argument 1 is of type int

我猜测可能是torch版本不一致导致的这个问题。 我的版本号: torch: 1.8.0 cuda: 12.6 python: 3.8

此外,如果我将这部分代码直接注释掉,程序也可以正常运行并产生正常结果。所以,好像不修复这个bug也可以。

jqsun98 avatar May 29 '25 03:05 jqsun98

我们finetune的环境如下: torch: 2.1.0 cuda:12.2 python: 3.10.12

jinyaoWHU avatar May 29 '25 07:05 jinyaoWHU