Why I keep receiving this message: "For deep learning, the simulation target language must be set to C++"?

조회 수: 16 (최근 30일)
I am using MATLAB R2021b (the latest version). This error also occured in the previous version.
I replaced the "RL Agent" block with a "MATLAB Function" block containing the policy generated for my controller.
I keep receiving this message even after I changed the taget language from "C" to 'C++".
For deep learning, the simulation target language must be set to C++. Function 'MATLAB Function' (#66.286.341), line 13, column 11: "coder.loadDeepLearningNetwork('agentData.mat','policy')" Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Persistent variable 'policy' must be assigned before it is used. The only exception is a check using 'isempty(policy)' that can be performed prior to assignment. Function 'MATLAB Function' (#66.398.404), line 16, column 19: "policy" Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Function call failed. Function 'MATLAB Function' (#66.140.167), line 7, column 11: "localEvaluate(observation1)" Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Errors occurred during parsing of MATLAB function 'IntegratedSys/MATLAB Function'
Component:MATLAB Function | Category:Coder error
Errors occurred during parsing of MATLAB function 'IntegratedSys/MATLAB Function'
This is the code inside the "MATLAB Function" blcok (which I generated it using the function "generatePolicyFunction"):
function action1 = evaluatePolicy(observation1)
%#codegen
% Reinforcement Learning Toolbox
% Generated on: 26-Sep-2021 07:01:45
action1 = localEvaluate(observation1);
end
%% Local Functions
function action1 = localEvaluate(observation1)
persistent policy
if isempty(policy)
policy = coder.loadDeepLearningNetwork('agentData.mat','policy');
end
observation1 = observation1(:)';
action1 = predict(policy, observation1);
end
  댓글 수: 3
Ismaeel
Ismaeel 2021년 9월 26일
Thank you Walter.
I am not professional in this filed and this term is new to me. I was wondering if there is a suported version of it or anything else that solves the problem.
I am also wondering why the message is not clear to the user. I followed what the message tells me and changed the setting accordingly, however, nothing changed.
Walter Roberson
Walter Roberson 2021년 9월 26일
Supported in R2021b for those purposes:
MinGW 6.3 C/C++ (Distributor: mingw-w64) Available at no charge
Microsoft Visual C++ 2019 product family
Microsoft Visual C++ 2017 product family

댓글을 달려면 로그인하십시오.

답변 (1개)

宝
2022년 7월 25일
Is 2022 now,this question still here!
  댓글 수: 1
Walter Roberson
Walter Roberson 2022년 7월 25일
The original poster was trying to use LCC-win64 2.4.1 as the compiler, but R2021b supports only MinGW 6.3, VS 2019, and VS 2017 for those purposes.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by