Not enough input arguments for 'bayesopt'?
Afficher commentaires plus anciens
Hello,
I just started with MATLAB today and was doing most of my work in Python so far. I need to use MATLAB for some specific project and im lost. I wanted to use BayesianOptimization tool 'bayesopt', but i can't seem to get it to work even for simple tasks.
My code:
x=optimizableVariable('x1',[-1 1]);
BayesObject=bayesopt(fun1,[x]);
fun1(0);
function y=fun(x)
y=x^2;
end
function [objective] = fun1(x)
objective=x^2
end
Which returns errors:
>> PythonTest
Not enough input arguments.
Error in PythonTest>fun1 (line 13)
objective=x.^2
Error in PythonTest (line 3)
BayesObject=bayesopt(fun1,[x]);
I hope someone can help me. Thank you very much.
Réponses (1)
Alan Weiss
le 13 Mar 2019
1 vote
Please look at the documentation on Bayesian objective functions. The bayesopt solver passes a table to the objective function. To access variables in the table, use dot notation.
function y = fun(t)
y = t.x1^2;
end
Alan Weiss
MATLAB mathematical toolbox documentation
2 commentaires
Luka Znidaric
le 13 Mar 2019
Aden Lee
le 18 Mai 2020
Mind to share what changes you have made to your code ? I'm interested.
Catégories
En savoir plus sur Classification dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!