bayesopt of patternet in classification problems

1 vue (au cours des 30 derniers jours)
Giovanni Barbarossa
Giovanni Barbarossa le 20 Avr 2020
I would like to optimize the variables of patternet for a classification problem using bayesopt. I found online the example below which optimizes the number of hidden layers and the learning rate:
% Define a train/validation split to use inside the objective function
cv = cvpartition(numel(YTrain), 'Holdout', 1/3);
% Define hyperparameters to optimize
vars = [optimizableVariable('hiddenLayerSize', [1,20], 'Type', 'integer');
optimizableVariable('lr', [1e-3 1], 'Transform', 'log')];
% Optimize
minfn = @(T)kfoldLoss(XTrain', YTrain', cv, T.hiddenLayerSize, T.lr);
results = bayesopt(minfn, vars,'IsObjectiveDeterministic', false, ...
'AcquisitionFunctionName', 'probability-of-improvement', ...
'MaxObjectiveEvaluations',20);
function rmse = kfoldLoss(x, y, cv, numHid, lr)
% Train net.
net = patternnet(numHid, 'traingd');
net.trainParam.lr = lr;
net = train(net, x(:,cv.training), y(:,cv.training));
% Evaluate on validation set and compute rmse
ypred = net(x(:, cv.test));
rmse = sqrt(mean((ypred - y(cv.test)).^2));
end
%
Which other variables of patternet can I optimize? Can I optimize them all? Is there an official Matlab documentation for patternet like there is one for fitcensemble to optimize the hyperparameters in classification problems using bayesopt? I can’t find in the official Matlab documentation the variables of patternet that I can actually optimize, and then how to implement them in the code above. I found epochs, goal and others but only in some examples online.
Thanks

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by