Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
liu0527aa opened this issue Nov 18, 2021 · 0 comments

Comments

@liu0527aa
Copy link

When I use the code to train, I met the problem.

Traceback (most recent call last):
File "/home/liuyh/pycharm-community-2021.2.2/plugins/python-ce/helpers/pydev/pydevd.py", line 1483, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "/home/liuyh/pycharm-community-2021.2.2/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/liuyh/demo/TPN-master/tools/train_recognizer.py", line 90, in
main()
File "/home/liuyh/demo/TPN-master/tools/train_recognizer.py", line 86, in main
logger=logger)
File "/home/liuyh/demo/TPN-master/mmaction/apis/train.py", line 60, in train_network
_non_dist_train(model, dataset, cfg, validate=validate)
File "/home/liuyh/demo/TPN-master/mmaction/apis/train.py", line 194, in _non_dist_train
runner.run(data_loaders, cfg.workflow, cfg.total_epochs)
File "/home/liuyh/miniconda3/envs/tpn/lib/python3.6/site-packages/mmcv/runner/runner.py", line 358, in run
epoch_runner(data_loaders[i], **kwargs)
File "/home/liuyh/miniconda3/envs/tpn/lib/python3.6/site-packages/mmcv/runner/runner.py", line 264, in train
self.model, data_batch, train_mode=True, **kwargs)
File "/home/liuyh/demo/TPN-master/mmaction/apis/train.py", line 37, in batch_processor
losses = model(**data)
File "/home/liuyh/miniconda3/envs/tpn/lib/python3.6/site-packages/torch/nn/modules/module.py", line 493, in call
result = self.forward(*input, **kwargs)
File "/home/liuyh/miniconda3/envs/tpn/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 150, in forward
return self.module(*inputs[0], **kwargs[0])
File "/home/liuyh/miniconda3/envs/tpn/lib/python3.6/site-packages/torch/nn/modules/module.py", line 493, in call
result = self.forward(*input, **kwargs)
File "/home/liuyh/demo/TPN-master/mmaction/models/recognizers/base.py", line 39, in forward
return self.forward_train(num_modalities, img_meta, **kwargs)
File "/home/liuyh/demo/TPN-master/mmaction/models/recognizers/TSN2D.py", line 115, in forward_train
x = self.segmental_consensus(x)
File "/home/liuyh/miniconda3/envs/tpn/lib/python3.6/site-packages/torch/nn/modules/module.py", line 493, in call
result = self.forward(*input, **kwargs)
File "/home/liuyh/demo/TPN-master/mmaction/models/tenons/segmental_consensuses/simple_consensus.py", line 62, in forward
self.consensus_type)
TypeError: save_for_backward can only save variables, but argument 1 is of type int
python-BaseException

Process finished with exit code 1

Can you give me some suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant