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

执行wekws/examples/speechcommand_v1/s0/run.sh 报错:KeyError: 'num_layers' #161

Open
taorui-plus opened this issue May 6, 2024 · 2 comments

Comments

@taorui-plus
Copy link

Describe the bug

执行wekws/examples/speechcommand_v1/s0/run.sh
报错:

Traceback (most recent call last):
  File "wekws/bin/export_onnx.py", line 105, in <module>
    main()
  File "wekws/bin/export_onnx.py", line 45, in main
    num_layers = configs['model']['backbone']['num_layers']
KeyError: 'num_layers'

查看代码需要在配置文件中读取这个参数
查看配置文件没有num_layers这个参数

To Reproduce

在配置文件中设置num_layers=16,生成了ONNX文件,但是报错:

Export model successfully, see exp/mdtc_epoch10/avg_10.zip
/dev/shm/taorui/taorui/wekws/wekws/model/mdtc.py:247: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if in_cache.size(0) > 0:
/dev/shm/taorui/taorui/wekws/wekws/model/mdtc.py:106: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if cache.size(0) == 0:
/dev/shm/taorui/taorui/wekws/wekws/model/mdtc.py:110: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  assert outputs.size(2) > self.padding
/dev/shm/taorui/taorui/wekws/wekws/model/mdtc.py:257: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if in_cache.size(0) > 0:
/dev/shm/taorui/taorui/wekws/wekws/model/mdtc.py:187: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if in_cache.size(0) > 0:
Receptive Fields: 244
some model information
Export to onnx succeed, but pytorch/onnx have different
                 outputs when given the same input, please check!!!....'
@mlxu995
Copy link
Collaborator

mlxu995 commented May 6, 2024

@taorui-plus 你可以试下设置 num_layers=4,应该能解决导出的问题。
这个 error 是因为 mdtc 和 tcn 中表示层数的变量名称不一致导致的,tcn 里的 num_layers 实际上对应于 mdtc 中的 num_stack

@zhuleia
Copy link

zhuleia commented Oct 9, 2024

在配置文件中加了num_layers=4,但在执行wekws/examples/speechcommand_v1/s0/run.sh的时候,报以下错误:
/home/zl/work/face/SpeechRecognition/wekws/wekws/model/mdtc.py:247: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
if in_cache.size(0) > 0:
/home/zl/work/face/SpeechRecognition/wekws/wekws/model/mdtc.py:106: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
if cache.size(0) == 0:
/home/zl/work/face/SpeechRecognition/wekws/wekws/model/mdtc.py:110: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
assert outputs.size(2) > self.padding
/home/zl/work/face/SpeechRecognition/wekws/wekws/model/mdtc.py:257: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
if in_cache.size(0) > 0:
/home/zl/work/face/SpeechRecognition/wekws/wekws/model/mdtc.py:187: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
if in_cache.size(0) > 0:
Export to onnx succeed, but pytorch/onnx have different
outputs when given the same input, please check!!!

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

3 participants