I'm trying to apply conditional constraints on two variable with bayesopt

조회 수: 3 (최근 30일)
muhamed ibrahim
muhamed ibrahim 2022년 7월 27일
답변: Alan Weiss 2022년 8월 2일
here are part the paramters i'm trying to optimize
optimVars = [optimizableVariable('numlayers',[20 25],'Type','integer')
optimizableVariable('LR',[1e-3 1e-1],'Transform','log')
optimizableVariable('MBS',[20 32],'Type','integer')
optimizableVariable('RP',[1e-3 1e-1],'Transform','log')];
function Xnew = condvariablefcn(X)
Xnew=X;
Xnew.L2Regularization(Xnew.numLayersToFreeze==24) = NaN;
end
but when i run the code, i get this message :
Error using BayesianOptimization/applyXConstraint
The XConstraintFcn must return a logical column vector the same height as
its input (10000), but it returned an object of class table with size
[10000 4].
the code runs fine before i added this constraint. so what is the problem with the function?

답변 (1개)

Alan Weiss
Alan Weiss 2022년 8월 2일
I think that you set the wrong name-value argument for your constraint function. bayesopt thinks that you are using an XConstraint, not a conditional constraint. In your bayesopt call set the name-value argument like this:
results = bayesopt(fun,vars,'ConditionalVariableFcn',@condvariablefcn)
Alan Weiss
MATLAB mathematical toolbox documentation

카테고리

Help CenterFile Exchange에서 Model Building and Assessment에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by