필터 지우기
필터 지우기

I keep getting the error "Index exceeds array bounds".

조회 수: 2 (최근 30일)
zain yousaf
zain yousaf 2020년 6월 3일
% INITIALIZE THE NEURAL NETWORK PROBLEM %
% inputs for the neural net(AND gate example== 2 inputs && 4 samples)
inputs = inputs';
% targets for the neural net
targets = TargetNormalized';
% number of neurons
n = 4;
% create a neural network
net = feedforwardnet(n);
% configure the neural network for this dataset
net = configure(net, inputs, targets);
% get the normal NN weights and bias
getwb(net)
% error MSE normal NN
error = targets - net(inputs);
calc = mean(error.^2)/mean(var(targets',1))
% create handle to the MSE_TEST function, that
% calculates MSE
h = @(x) NMSE(x, net, inputs, targets);
% Setting the Genetic Algorithms tolerance for
% minimum change in fitness function before
% terminating algorithm to 1e-8 and displaying
% each iteration's results.
% PLEASE NOTE: For a feed-forward network
% with n hidden neurons, 3n+n+1 quantities are required
% in the weights and biases column vector.
% a. n for the input weights=(features*n)=2*n
% b. n for the input biases=(n bias)=n
% c. n for the output weights=(n weights)=n
% d. 1 for the output bias=(1 bias)=1
% running the particle swarm optimization algorithm with desired options
[x, err_ga] = pso(h, 2*n+n+n+1)
net = setwb(net, x');
% get the PSO optimized NN weights and bias
getwb(net)
% error MSE PSO optimized NN
error = targets - net(inputs);
calc = mean(error.^2)/mean(var(targets',1))
% Index exceeds array bounds.
Error in separatewb (line 34)
iw{i,j} = reshape(wb(hints.iwInd{i,j}),...
Error in setwb (line 23)
[b,IW,LW] = separatewb(net,wb,hints);
Error in NMSE (line 7)
net = setwb(net, wb);
Error in main>@(x)NMSE(x,net,inputs,targets)
Error in pso (line 67)
particle(i).Cost=CostFunction(particle(i).Position);
Error in main (line 43)
[x, err_ga] = pso(h, 2*n+n+n+1)
Im keep geeting this error, no solution

답변 (0개)

카테고리

Help CenterFile Exchange에서 Particle Swarm에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by