Codegen respond with an error: "??Expected a character vector. "

When I use my training results of DDPG model to generate GPU code, there always respond an error. I followed the instruction "Deploy Trained Reinforcement Learning Policies" from help document, and it runs well in other exmples. Here is error report:
And return code:
>>codegen('-config','cfg','evaluatePolicy','-args',argstr,'-report');
??? Expected a character vector.
Code generation failed: View Error Report
Incorrect use of codegen

7 件のコメント

Emmanouil Tzorakoleftherakis
Emmanouil Tzorakoleftherakis 2021 年 5 月 13 日
can you provide the rest of the code you are running? The doc page has some steps before running 'codegen'. For example what is 'cfg'? It seems there is a typo somewhere based on the error msg
Haonan Ding
Haonan Ding 2021 年 5 月 13 日
"cfg" is a command from the sample in the topic “Deploy Trained Reinforcement Learning Policies” in the MATLAB help document, and here is the online link: "https://ww2.mathworks.cn/help/reinforcement-learning/ug/deploy-trained-reinforcement-learning-agents.html".
I have tried the second way "Generate Code Using MATLAB Coder", and it still has same issue.
cfg = coder.gpuConfig('mex');
cfg.TargetLang = 'C++';
cfg.DeepLearningConfig = coder.DeepLearningConfig('cudnn');
argstr = '{ones(4,1)}'; % "argstr = '{ones(5,1)}';" for my case
codegen('-config','cfg','evaluatePolicy','-args',argstr,'-report');
伯儒 周
伯儒 周 2021 年 9 月 7 日
移動済み: Voss 2024 年 4 月 14 日
Hi, Haonan Ding. Did you solve this problem? I met the same problem when I code a deep learning network follow the help document, I guess the problem may be resulted by the character vector input 'agenData.mat' and 'policy' but I cannot solve it just like you.
伯儒 周
伯儒 周 2021 年 9 月 8 日
I know how to solve the problem!
You should creat a new folder and the path can not contain any chinese symbal and the coder will work.
XingZhou Mu
XingZhou Mu 2024 年 4 月 14 日
移動済み: Voss 2024 年 4 月 14 日
Hello, did you solve this problem, I am also having the same problem
XingZhou Mu
XingZhou Mu 2024 年 4 月 14 日
Hello, did you solve this problem, I am also having the same problem
Jie Li
Jie Li 2024 年 5 月 9 日
竟然是中文路径的问题!改成英文路径就OK了

サインインしてコメントする。

回答 (1 件)

Paras Gupta
Paras Gupta 2024 年 6 月 21 日

0 投票

Hello Haonan,
I understand that you're encountering the error "??? Expected a character vector."
This issue could arise if the name of the specified MAT-file or the absolute file path to the MAT-file contains non-ASCII characters, which are not supported by codegen. Please refer to the 'Limitations' section of the following documentation.
You can also refer to the below documentation for more information on character encoding in code generation:
Hope this resolves the query.

カテゴリ

ヘルプ センター および File ExchangeDeep Learning Code Generation Fundamentals についてさらに検索

質問済み:

2021 年 5 月 8 日

回答済み:

2024 年 6 月 21 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by