Error generating code to implement RegressionGP Model using MATLAB Function in Simulink (The input to coder.const cannot be reduced to a constant: Unsupported value.)

3 ビュー (過去 30 日間)
A strange problem occurs to me trying to integrate my trained RegressionGP in a Simulink Model using a MATLAB Function block, saveLearnerForCoder and loadLearnerForCoder.
I trained two GPs with the same size of predictors which is 75. I use the same script for training and optimization. The only difference are the measurements used for training. I use sequences of 25 datapoints from three sensors each.
The first GP works flawlessly in a matlab skript ans also in Simulink using a MATLAB Function block. The second GP works without problem in a MATLAB script. When I try to complie the same Simulink model with the second GP (change name of file in loadLearnerForCoder) I get the following error:
The input to coder.const cannot be reduced to a constant: Unsupported value. Function 'loadLearnerForCoder.m' (#76.1874.1895), line 41, column 68: "matFile.compactStruct" Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Function call failed. Function 'MATLAB Function2' (#55.201.239), line 10, column 7: "loadLearnerForCoder('gprMdl_V106_LUT')" Launch diagnostic report.
This is the function I use in both cases:
function [prediction, upperConf, lowerConf] = gpr_predict_V101(X) %#codegen
% Copyright 2019 The MathWorks, Inc.
prediction = 0.0;
confidence = [ 0.0 0.0 ];
upperConf = 0.0;
lowerConf = 0.0;
mdl = loadLearnerForCoder('gprMdl_V101_LUT');
[prediction, ~, confidence] = predict(mdl,X);
upperConf = confidence(:,1);
lowerConf = confidence(:,2);
end
The input data is preprocess the same way for both GPs and therefore has the same size. I checked all dimensions and compared the compacStruct created for both GP through saveLearnerForCoder and couldn't finde any difference besides the GP hyperparameters and ActiveSet used.
Does anyone know where else this error could come from?
Thanks in advance!

採用された回答

Denis Gurchenkov
Denis Gurchenkov 2020 年 8 月 4 日
Hi Michelle, there is nothing wrong with your code, the issue looks like a bug in the product. Can you please contact MathWorks technical support, just tell the support person to route the ticket to MATLAB Coder team (this is where I work). If you are able to provide your (failing) model to the technical support, we should be able to reproduce the issue in-house and figure out what is going on and hopefully provide you with some workaround.
Thanks!

その他の回答 (1 件)

Sriram Padavettan
Sriram Padavettan 2020 年 12 月 4 日
Not sure if you figured it out yet, but are you using 2020A?
I had same issue and messed with it all day until I decided to try a different version and it worked - try 2020B.
  1 件のコメント
Michelle Geilenberg
Michelle Geilenberg 2020 年 12 月 6 日
Hi Sriram,
that is actually also the solution the Mathworks Support Team came up with. I had to wait a month for the 2020b release and was able to run my simulation without problems! Apparently there is a bug in the MATLAB Coder which gets resolved in R2020b.
Thanks for your help anyways! :)
Michelle

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

カテゴリ

Help Center および File ExchangeGaussian Process Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by