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 Center および File ExchangeModel Building and Assessment についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by