How to use a trained neural network as objective function in fminsearch?

조회 수: 10 (최근 30일)
I have trained a neural network, with input x that is a matrix 12x22000 and a target t 1x22000, and i have got an output y 1x22000, now i want to optimaize one element of my output with the tool fminsearch but i don't know how to write the objective function 'fun'.
What should i put as 'fun'?
x = input;
t = output;
trainFcn = ['trainlm'];
hiddenLayerSize = 50;
net = feedforwardnet(hiddenLayerSize,trainFcn);
net.divideFcn = ['divideblock'];
net.performFcn = 'mse';
[net,tr] = train(net,x,t);
y = net(x);
%now i want use fminsearch(fun,x0,options)
  댓글 수: 2
Matt J
Matt J 2022년 9월 19일
편집: Matt J 2022년 9월 19일
Optimize with respect to what unknowns? If you are trying to refine the weights, the output surely depends on many, many network weight parameters, which is not suitable for fminsearch.
Leonardo Anzellotti
Leonardo Anzellotti 2022년 9월 20일
optimize with respect to the 12 input variables for each output

댓글을 달려면 로그인하십시오.

채택된 답변

Matt J
Matt J 2022년 9월 20일
fminsearch.is unlikely to be able to handle 12 unknowns well. You should probably use fminunc if you have the Optimization Toolbox. Either way, the 'fun' input would be,
fun=@(x) net(x);
  댓글 수: 1
Saurabh Sharma
Saurabh Sharma 2023년 12월 16일
편집: Saurabh Sharma 2023년 12월 16일
How can we get a trained Gaussian process regression machine learning model in a mathematical equation form? How to write 'fun' if we want to minimise three or four models at same time?
Thankyou

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by