One, core extreme learning machine
This paper introduces a new SLFN algorithm, extreme learning machine, the algorithm will be randomly generated between input layer and hidden layer connection weights and threshold of hidden layer neurons, and no adjustment in the process of training, only need to set the number of neurons in hidden layer, can obtain the optimal solution only, compared with the traditional training methods, This method has the advantages of fast learning rate and good generalization performance.
The typical single hidden layer feedforward neural network is shown in the figure above. The input layer is fully connected with the hidden layer, and the hidden layer is fully connected with the output layer. The number of neurons in the input layer is determined according to the number of samples and the number of features, and the number of neurons in the output layer is determined according to the number of types of samples
Let the threshold b of neurons in the hidden layer be:
When the number of neurons in the hidden layer is the same as the number of samples, equation (10) has a unique solution, that is to say, the training sample is approached with zero error. In the usual learning algorithm, W and B need constant adjustment, but the research results show that they do not need constant adjustment, and can even be specified at will. Adjusting them takes time and does not offer much benefit. (Suspect, probably out of context, this conclusion may be based on some premise).
Two, sparrow algorithm
Optimization problem is a hot topic in scientific research and engineering practice. Most intelligent optimization algorithms are inspired by human intelligence, biological society or natural phenomena, and carry out global optimization in the solution space. Sparrow algorithm was first proposed by Xue Jiankai [1] in 2020. It is a new intelligent optimization algorithm based on the foraging and anti-predation behavior of sparrow population.
The detailed steps and formula of sparrow search algorithm are described:
Construction of sparrow population:
Where, D represents the dimension of the problem to be optimized, and n represents the number of sparrow population. The fitness function of all sparrow populations can be expressed as follows:
Where, Fx represents the fitness function value.
The sparrows in the Sparrow algorithm are divided into two categories: discoverers and entrants. The discoverers are responsible for searching for food for the whole population and providing foraging directions for entrants. Therefore, the search range of the discoverers is larger than that of the entrants. During each iteration, the discoverer iterates according to formula (3).
T said the current number of iterations, Xij said of the ith the sparrow population in the first j d location information, alfa said random number of 0 and 1, itermax said the largest number of iterations, Q means a obey the normal distribution of random Numbers, L is a 1 * d and all elements of 1 matrix, R2 belong to early warning value of 0 and 1 is the location of the sparrow population, ST belongs to 0.5-1, which indicates the safe value of sparrow population position.
When R2<ST, it means that the warning value is less than the safe value. At this time, there is no predator in the foraging environment, and the finder can conduct extensive search operations. When R2>ST, it means that some sparrows in the population have found the predator and sent an early warning to other sparrows in the population. All sparrows need to fly to a safe area for foraging.
In the process of foraging, some entrants will monitor the finder all the time. When the finder finds better food, the entrant will compete with it. If successful, the entrant will get the finder’s food immediately; otherwise, the entrant will update the position according to formula (4).
Where, XP represents the optimal position discovered by the discoverer, Xworst represents the global worst position, and A represents the 1*d matrix whose elements are randomly assigned to 1 or -1 and satisfy the following relationship:
L is still a 1 by d matrix with all 1’s. When I >n/2, it indicates that the ith participant does not get food and is in a state of hunger. At this time, he needs to fly to other places to forage for food to obtain more energy.
The positions of the endangered sparrows, which account for 10 to 20 percent of the sparrow population, are randomly generated, and the positions of the aware sparrows are constantly updated according to formula (5).
Where, Xbest represents the current global optimal position, is the random number obeying the standard normal distribution and used as the step size control parameter, beta is a random number belonging to -1 to 1, FI is the fitness value of the current sparrow individual, FG is the global best fitness value, fw is the global worst fitness value, The one that looks like the left ear, does that read “One not one”? “One no wash” means a constant that avoids having a zero denominator. When fi> FG, it means that sparrows are at the edge of the population and are easily attacked by predators; when FI = FG, it means that sparrows in the middle of the population are also in danger and need to stay close to other sparrows to reduce the risk of predation.
Three, code,
function [FoodFitness,FoodPosition,Convergence_curve]=SSA(N,Max_iter,lb,ub,dim,fobj) if size(ub,1)==1 ub=ones(dim,1)*ub; lb=ones(dim,1)*lb; end Convergence_curve = zeros(1,Max_iter); %Initialize the positions of salps SalpPositions=initialization(N,dim,ub,lb); FoodPosition=zeros(1,dim); FoodFitness=inf; %calculate the fitness of initial salps for i=1:size(SalpPositions,1) SalpFitness(1,i)=fobj(SalpPositions(i,:)); end [sorted_salps_fitness,sorted_indexes]=sort(SalpFitness); for newindex=1:N Sorted_salps(newindex,:)=SalpPositions(sorted_indexes(newindex),:); end FoodPosition=Sorted_salps(1,:); FoodFitness=sorted_salps_fitness(1); %Main loop l=2; % start from the second iteration since the first iteration was dedicated to calculating the fitness of salps while l<Max_iter+1 c1 = 2*exp(-(4*l/Max_iter)^2); % Eq. (3.2) in the paper for I =1:size(SalpPositions,1) SalpPositions= SalpPositions'; if i<=N/2 for j=1:1:dim c2=rand(); c3=rand(); % % % % % % % % % % % % % % Eq. (3.1) in the paper % % % % % % % % % % % % % % if c3 < 0.5 SalpPositions(j,i)=FoodPosition(j)+c1*((ub(j)-lb(j))*c2+lb(j)); else SalpPositions(j,i)=FoodPosition(j)-c1*((ub(j)-lb(j))*c2+lb(j)); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% end elseif i>N/2 && i<N+1 point1=SalpPositions(:,i-1); point2=SalpPositions(:,i); SalpPositions(:,i)=(point2+point1)/2; % % Eq. (3.4) in the paper end SalpPositions= SalpPositions'; end for i=1:size(SalpPositions,1) Tp=SalpPositions(i,:)>ub'; Tm=SalpPositions(i,:)<lb'; SalpPositions(i,:)=(SalpPositions(i,:).*(~(Tp+Tm)))+ub'.*Tp+lb'.*Tm; SalpFitness(1,i)=fobj(SalpPositions(i,:)); if SalpFitness(1,i)<FoodFitness FoodPosition=SalpPositions(i,:); FoodFitness=SalpFitness(1,i); end end Convergence_curve(l)=FoodFitness; l = l + 1; endCopy the code
Four, references and code private message blogger