Open haochuan-li opened 12 months ago
Sorry, mmengine does not support torch's optimizer now. To observe the gradient in custom dataset, you can override BaseModel.train_step, where the forward function returns a differentiable loss dict when its parameter mode='loss' or 'tensor'. You may get the gradient from the loss dict. For more information about the loss dict, see forward function in https://mmengine.readthedocs.io/en/latest/tutorials/model.html
Prerequisite
Environment
sys.platform: linux Python: 3.9.18 | packaged by conda-forge | (main, Aug 30 2023, 03:49:32) [GCC 12.3.0] CUDA available: True numpy_random_seed: 2147483648 GPU 0,1,2,3,4,5,6,7: Tesla V100-SXM2-32GB CUDA_HOME: /usr/local/cuda-11.7 NVCC: Cuda compilation tools, release 11.7, V11.7.64 GCC: gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0 PyTorch: 2.0.1+cu117 PyTorch compiling details: PyTorch built with:
TorchVision: 0.15.2+cu117 OpenCV: 4.8.1 MMEngine: 0.9.0 MMAction2: 1.2.0+4d6c934 MMCV: 2.1.0
Reproduces the problem - code sample
Hi! I wonder is it possible to change the dataset settings and add optimizer to parameters other than model parameters when using Runner. For example,
Can anyone enlighten me on this? Thanks.
Hi! I wonder is it possible to change the dataset settings and add optimizer to parameters other than model parameters when using Runner. For example,
Can anyone enlighten me on this? Thanks.
Reproduces the problem - command or script
53 Traceback (most recent call last): 54 File "/home/wangkai/miniconda3/envs/vdd/lib/python3.9/site-packages/yapf/pytree/pytree_utils.py", line 113, in ParseCodeToTree 55 tree = parser_driver.parse_string(code, debug=False) 56 File "/home/wangkai/miniconda3/envs/vdd/lib/python3.9/site-packages/yapf_third_party/_ylib2to3/pgen2/driver.py", line 188, in parse_string 57 return self.parse_tokens(tokens, debug) 58 File "/home/wangkai/miniconda3/envs/vdd/lib/python3.9/site-packages/yapf_third_party/_ylib2to3/pgen2/driver.py", line 157, in parse_tokens 59 if p.addtoken(type, value, (prefix, start)): 60 File "/home/wangkai/miniconda3/envs/vdd/lib/python3.9/site-packages/yapf_third_party/_ylib2to3/pgen2/parse.py", line 230, in addtoken 61 return self._addtoken(ilabel, type, value, context) 62 File "/home/wangkai/miniconda3/envs/vdd/lib/python3.9/site-packages/yapf_third_party/_ylib2to3/pgen2/parse.py", line 313, in _addtoken 63 raise ParseError('bad input', type, value, context) 64 yapf_third_party._ylib2to3.pgen2.parse.ParseError: bad input: type=20, value='<', context=('', (168, 17)) 65 During handling of the above exception, another exception occurred: 66 Traceback (most recent call last): 67 File "/home/wangkai/miniconda3/envs/vdd/lib/python3.9/site-packages/yapf/yapflib/yapf_api.py", line 198, in FormatCode 68 tree = pytree_utils.ParseCodeToTree(unformatted_source) 69 File "/home/wangkai/miniconda3/envs/vdd/lib/python3.9/site-packages/yapf/pytree/pytree_utils.py", line 116, in ParseCodeToTree 70 ast.parse(code) 71 File "/home/wangkai/miniconda3/envs/vdd/lib/python3.9/ast.py", line 50, in parse 72 return compile(source, filename, mode, flags, 73 File "", line 168
74 train_dataloader=<torch.utils.data.dataloader.DataLoader object at 0x7ff7773939a0>
75 ^
76 SyntaxError: invalid syntax
77 During handling of the above exception, another exception occurred:
78 Traceback (most recent call last):
79 File "/home/wangkai/miniconda3/envs/vdd/lib/python3.9/site-packages/mmengine/config/config.py", line 1477, in prettytext
80 text, = FormatCode(text, style_config=yapf_style)
81 File "/home/wangkai/miniconda3/envs/vdd/lib/python3.9/site-packages/yapf/yapflib/yapf_api.py", line 201, in FormatCode
82 raise errors.YapfError(errors.FormatErrorMsg(e))
83 yapf.yapflib.errors.YapfError: :168:18: invalid syntax
84 During handling of the above exception, another exception occurred:
85 Traceback (most recent call last):
86 File "/home/ssd7T/haochuan/mmaction2/tools/custom_train.py", line 347, in
87 main()
88 File "/home/ssd7T/haochuan/mmaction2/tools/custom_train.py", line 336, in main
89 # runner = Runner.from_cfg(cfg)
90 File "/home/wangkai/miniconda3/envs/vdd/lib/python3.9/site-packages/mmengine/runner/runner.py", line 462, in from_cfg
91 runner = cls(
92 File "/home/wangkai/miniconda3/envs/vdd/lib/python3.9/site-packages/mmengine/runner/runner.py", line 403, in init
93 self._log_env(env_cfg)
94 File "/home/wangkai/miniconda3/envs/vdd/lib/python3.9/site-packages/mmengine/runner/runner.py", line 2388, in _log_env
95 self.logger.info(f'Config:\n{self.cfg.pretty_text}')
96 File "/home/wangkai/miniconda3/envs/vdd/lib/python3.9/site-packages/mmengine/config/config.py", line 1482, in pretty_text
97 raise SyntaxError('Failed to format the config file, please '
98 SyntaxError: Failed to format the config file, please check the syntax of:
Additional information
No response