# how can I optimize a neural network with multiple outputs using the Genetic Algorithm ?

11 ビュー (過去 30 日間)
Yousra TOUAMI 2022 年 5 月 6 日
コメント済み: Yahya 2022 年 11 月 15 日
Hello,
I have trained a neural network using the Neural net fitting app, my neural network have 3 inputs and 4 outputs. I want to optimize the neural network using the Genetic Algorithm but the problem is whenever I use the optimization app and include the following script I always get an error telling me that my neural network has several outputs and that the app only takes one output at a time to be able to give me the optimal conditions. ( For more info I am trying to optimize my neural network so that it gives me the optimal conditions to maximize my 4 outputs at the same time). Is there a way can change the script so that it can work with 4 outputs or is it impossible to do with the Genetic algorithm.
function y = fonc(x)
net = saveVarsMat.net;
y = -(net(x'));
##### 1 件のコメント表示非表示 なし
Yahya 2022 年 11 月 15 日
Hi .... Yousra
I have same issue
Did u find solution

サインインしてコメントする。

### 回答 (1 件)

Alan Weiss 2022 年 5 月 6 日
Generally speaking, optimization algorithms try to minimize a single scalar function of the input variables x. I don't know what your neural network is outputting that you are trying to "optimize," where I put that word in quotes because I am not sure that you are trying to minimize something.
Sometimes people want to minimize a difference between an output vector fonc(x) and a known vector known. In that case, the usual objective function is the sum of squares of differences:
f = sum((fonc(x) - known).^2);
Alan Weiss
MATLAB mathematical toolbox documentation
##### 4 件のコメント表示非表示 3 件の古いコメント
Alan Weiss 2022 年 5 月 10 日
As I said before, you can look at the multiobjective solution (using gamultiobj or paretosearch) and choose the best tradeoff point on the Pareto front, where "best" means whatever you think is best. Or you can come up with a single scalar function that is "the totality of the outputs as a whole." I don't know what you mean by that, but if you can come up with a scalar mathematical expression then optimize that.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation

サインインしてコメントする。

### カテゴリ

Find more on Genetic Algorithm in Help Center and File Exchange

R2021a

### Community Treasure Hunt

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

Start Hunting!