Skip to content

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

Description

@liu0527aa

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions