12 views (last 30 days)
I have developed an neural network with 4 input nodes, 4 hidden nodes and one output node using feed forward back propagation network. Now I need to use GA to optimize and determine the maximum output. How to define the ANN model as the fitness function.
Seth DeLand on 28 Feb 2012
You can create a function handle to the network and then pass that function handle into GA. Note that GA will pass in a row vector, so if your NN accepts a column vector as input it will need to be transposed. Also, GA minimizes the objective function so we add the negative sign to flip it from a maximization problem to a minimization problem. For example:
objFcn = @(x) -sim(net,x'); % Function that simulates NN and returns output
[xOpt,fVal] = ga(objFcn, 4); % Find the minimum of objFcn with 4 inputs