Study on Waste Type Identification Method Based on Bird Flock Neural Network

According to the waste type identification requirement in waste classification, a waste type identification method based on a bird flock neural network (BFNN) was proposed. ,e problem of obtaining the feature dataset of waste images was considered, and color histogram and texture feature extraction techniques were used. ,e local optimum problem of a typical backpropagation neural network (BPNN) was considered, and a bird flock optimization (BFO) algorithm was proposed. ,e accuracy problem of the typical BPNN was considered, and a new online weight adjustment method of neurons was proposed. ,e number of hidden layer neurons (nodes) of the typical BPNN was considered, and an online adjustment method was proposed. ,e experimental results show that the recyclables (paper, plastic, glass, and cloth) and nonrecyclables can effectively be identified by the waste type identification method based on the BFNN, and the recognition accuracy is 81% which meets actual needs.


Introduction
"Shanghai Household Waste Management Regulation" had been implemented since July 2019. e domestic waste was divided into recyclables (including paper, plastic, glass, metal, and cloth) and nonrecyclables (including hazardous, wet, and dry waste) based on the regulation. Since waste classification is a heavy work, the intellectualization of waste classification has become an important topic.
In recent years, the study on neural network (NN) and image processing has been a research hotspot, but there are limited studies on waste classification using image processing and NN. Laser-induced breakdown spectrometry together with discriminant function analysis was used for the identification and classification of five groups of polymers in the electronics industry [1]. A thermal imagingbased system for classifying useful recyclables from simulated municipal solid waste (MSW) sample was reported, and the system could be used in recycling plants for processing MSW in developing countries [2]. An intelligent waste material classification system was proposed, which was developed by using the 50-layer residual net pretrained convolutional neural network (CNN) model [3]. Two reinforcement learning-based metalearning approaches, MetaQNN and efficient neural architecture search, were investigated and compared to find suitable CNN architectures for multitarget concrete defect classification with the COncrete DEfect Bridge IMage dataset [4].
In recent years, the study on NN and related optimization algorithm has been a research hotspot. e differential evolution-(DE-) based metaheuristic optimization algorithm was used for optimizing the search space of artificial neural network (ANN), and the effect of ANN-DEbased model predictions was better than the traditional quadratic model predictions [5]. Jicama peroxidase was immobilized on the surface modified buckypaper/polyvinyl alcohol membrane and employed for the application of methylene blue dye removal from aqueous solution, and the parameters of the isotherm and kinetic models were estimated using ant colony optimization (ACO) [6]. e GA-ANN method was used to select the most important features affecting soil erodibility to wind, and minimization of the cost function was better than comparison algorithm [7]. A new hybrid approach which combined the recurrent fuzzy neural network (RFNN) with particle swarm optimization (PSO) algorithm to simulate the flyrock distance induced by mine blasting [8]. ACO algorithm was employed with a modified heuristic value to obtain sparsely placed nodes in the solution, and the improved ACO was used for reducing the cost of wireless sensor networks and sensor nodes [9]. A new adaptive version of particle swarm optimizer was used for improving the robustness and the stability of the controller according to the climatic changes and overcoming the problem of local optimum [10]. A NN was used for designing sensors, the parameters were modeled by ANN and optimized by genetic algorithm (GA) within the practical levels, and the optimization process led to find the most accurate optimal conditions possible [11].
It is well known that CNN can directly extract image features, which is an important algorithm especially suitable for image classification [12][13][14]. However, CNN requires a long training time. Even if a GPU is used for calculation, some training processes of CNNs will take several hours or even days (it takes only a few seconds for the proposed algorithm in this paper). In this paper, an algorithm was proposed for solving the problem of waste identification and making theoretical preparation for manufacturing trash can which can automatically identify and classify waste. Because the computing power of hardware of trash can is usually limited, the CNN is not used.
NN is an effective method for classification. Trained NN can automatically identify the type of waste and sort the waste to a suitable location by hardware so as to save labor cost. Backpropagation neural network (BPNN) is a classic neural network; at present, BPNN has been applied in many fields [15][16][17]. ere are problems of local optimum [18], accuracy [19], and hidden layer neuron (nodes) adjustment [20] in a typical BPNN and other improved algorithms. According to the above problems, a bird flock neural network (BFNN) was proposed, and then a waste type identification method based on the BFNN was proposed.

Dataset Acquisition
e image features of waste were extracted to generate dataset, and the dataset was used as the input of NN. e type of waste was manually determined and coded, and the encoded data were used as the output of NN. e obtained dataset was used for training a NN. After training, the NN could identify the type of waste.

Obtaining Input Data.
e images of some waste are shown in Figure 1. e image features in Figure 1 were extracted to generate dataset, and the dataset was used as the input data of NN.

Extracting Feature Information of Color Histogram of Image.
e color histogram reflects the statistical characteristics of the color distribution of images, and it is suitable for describing images which are difficult to segment and do not need to consider the position of the object. A camera was used to capture the image within a fixed square, and the background was white. e captured result was an image with fixed size (200 × 200 pixel). Because the number of pixels in the image was fixed, the number of the pixels of certain color could be used as characteristic vector. e tricolor histogram of Figure 1(d) is shown in Figure 2.
In Figure 2, the abscissa is the pixel level, and the ordinate is the number of pixels. e number of 0-50 colored pixels of the red component histogram was captured as feature vector 1 e surface properties of images and corresponding objects are described by texture features. ree texture feature vectors including mean, contrast, and entropy were used in this paper.
Let (x, y) be a point in an image, and the calculation formula of gray difference between the point and another point (x + Δx, y + Δy) is as follows: Δg(x, y) � g(x, y) − g(x + Δx, y + Δy).
(1) e calculation formulas of mean, contrast, and entropy are as follows [21]: where mean is the average value, m is the number of gray level, i is the gray level number, p(i) is the probability of Δg(x, y), con is the contrast value, and entropy is the entropy value. e input of NN includes 15 color histogram feature vectors and 3 texture feature vectors and a total of 18 feature vectors.

Determining Output Data.
Recyclables were divided into 5 kinds: paper, plastic, glass, metal, and cloth. Metals could be directly identified by sensors, so there was no need to be identified by image features. erefore, the waste type identification method based on the BFNN was used to identify some recyclables (paper, plastic, glass, and cloth) and nonrecyclables by image features. e corresponding output of NN was in the order of 00001, 00010, 00100, 01000, and 10000.

Differences between BFNN and
Typical BPNN e structure of a BFNN is shown in Figure 3. ere are some characteristics of the BFNN in Figure 3. e network consists of at least three layers. e neurons in each layer are fully connected to the neurons in the next layer, and there is no connection between the neurons in the same layer. Because the BFNN is trained by offline algorithm and online algorithm, the accuracy of the algorithm can be guaranteed and the data can be added online. Because the BFNN uses online adjustment method, the number of the hidden layer neurons can be increased or decreased online. e main differences between BFNN and typical BPNN are as follows.

A Bird Flock Algorithm.
e bird flock optimization (BFO) algorithm is an intelligent optimization algorithm proposed in this paper, which will be compared with PSO [22,23]. e differences between BFO and PSO are as follows: (i) PSO. Each individual emulates its most successful neighbor by updating its velocity and position to Biological foundation: the process of bird flock seeking food.
e purpose of this operation: the BFO has the function of global optimum (preventing local optimum), and it is used to optimize the weights of the NN.

A New Weight Adjustment Method of Neurons.
e differences between the weight adjustment method of BFNN and typical BPNN are as follows: (i) Typical BPNN. e weight adjustment formulas of the typical BPNN can be found in literature [25,26]. (ii) BFNN. A new adjustment method is used to update the weights of neurons.
Biological foundation: the medium between two neurons changes when the neurons are continuously activated. e purpose of this operation: the new weight adjustment method of the BFNN can add data one by one for online learning, and it has better capabilities of local optimum.

An Online Adjustment Method of the Number of Hidden Layer Neurons.
e differences between the adjustment method of the number of the hidden layer of BFNN and typical BPNN are as follows: e typical BPNN obtains the number of the hidden layer neurons by empirical formula and repeated tests. Once the number of the hidden layer neurons is found, it cannot be increased or decreased.
(ii) BFNN. e BFNN obtains the number of the hidden layer neurons by empirical formula, and then the number of neurons is adjusted by the online adjustment method.
Biological foundation: the number of biological neurons is not fixed and can be increased or decreased. e purpose of this operation: the BFNN can increase or decrease the number of the hidden layer neurons online after the adjustment method is used.

Feedforward Calculation.
e process of feedforward calculation includes three parts: determining structure, preprocessing data, and calculating output values.

Determining Structure.
e number of input and output layer neurons was manually determined on the basis of dataset information.
e calculation formulas of the number of initial hidden layer neurons are as follows: where l is the number of hidden layer neurons, m is the number of input layer neurons, and n is the number of output layer neurons.

Preprocessing Data.
e dataset is normalized, and the calculation formula is as follows: where x is the original data, x ′ is the normalized data, x max is the maximum value of x, and x min is the minimum value of x. e normalized dataset was divided into four parts: training input, training output, test input, and test output.
where i is the input layer neuron number. For the convenience of writing, the sample number is omitted. e input data pass through the hidden layer to the output layer. e input of hidden layer is net where w ij is the weight between input layer and hidden layer. e output of hidden layer is O j (k) � f(net j (k)), where f is excitation function and j is the hidden layer neuron number. e excitation function is a hyperbolic tangent function, and the calculation formula is y  layer neuron number and k is the output layer neuron number. e output layer excitation function is a linear excitation function, and the output of output layer neurons is O k � net k .

BFO.
BFO is used to obtain a set of optimal weights of NN.
After the feedforward calculation, we need to determine if there is a known dataset. If yes, the BFO is used to train the NN, and the known data are mapped to the NN; if no, the algorithm flow jumps to Section 4.3.
e algorithm flow of the BFO is shown in Figure 4. In BFO, a bird flock is a group of individuals. A bird is an individual, and it is a set of weights of NN in this paper. e predation effect is fitness. Flight times are the iteration times of BFO. Surrounding birds are the individuals within a certain distance. e overall predation effect of bird flock is average fitness.
e principle of BFO is as follows.

Generating the Number of Initial
Birds. e accuracy and running speed of BFO will be considered by setting the appropriate number of birds in an initial flock. Increasing the number of birds will improve accuracy and increase time consumption of BFO and vice versa. BFO can evaluate dataset and automatically generate the appropriate number of birds based on dataset information. e algorithm for generating the number of the birds of initial flock is as follows.
Sort the value of each input vector from small to large, normalize them, and keep two decimal places. Add each different number to the abscissa and count the number of abscissa value of dataset into the ordinate. Remove ordinate points which are 0, connect adjacent points, and detect the peaks which are greater than the threshold b 1 in the graph, and the number of the peaks is denoted by peaknum i . Set the threshold b 2 ; if peaknum i > b 2 , then classnum i � peaknum i ; if peaknum i < b 2 , then classnum i � 1. Calculate t classnum based on (10).
where t classnum is the number of classes of dataset and classnum i is the number of classes on the i-th input vector of dataset. e calculation formula of the initial bird flock is as follows: where ininum is an integer between 10 and 200, and it is an integer multiple of 10.

Bird Flock Search
Strategy. e bird flock search strategy is as follows: (i) e birds which have better predation effect stay, and the birds which have poorer predation effect fly away. e birds which fly away do not prey near the staying birds, so as to ensure the predation effect of the whole flock.
Set appropriate fitness function according to project. If it is a classification project, the number of correct classification can be used as fitness. If it is a prediction project, the following formula can be used to calculate fitness: where fit is the fitness of individual, a value is the actual value of output, and p value is the predicted value of output. e average fitness, meanfit, is calculated after running the algorithm. e individuals which are below meanfit will be reset randomly, and the new individuals are not in a range of the generated individuals. After the NN is fully trained, it can be known that most of the weights of the NN are distributed between 0.1-1. e value of weights are rounded, and they are kept one decimal place. After the above Mathematical Problems in Engineering operation, the new individual and the old individual cannot be the same. If the two are the same, the new individual will be reset randomly. e above operation ensures that the new individual does not appear within a certain range of the old individual. is operation needs to set the upper limit of reset times (2 in this paper) to prevent an endless loop. e significance of strategy: (i) Ensure the individuals have the uniform distribution positions approximately in the dimensional space, and ensure each individual has a good initial fitness. is strategy can improve the global search performance and prevent the local optimum of NN. (ii) In a small area, the bird which has the best predation effect (called guide bird) will attract surrounding birds. e guide birds will attract nearby birds to search a smaller area together. e ininum individuals are sorted from high to low based on the fitness. e first 20% individuals are taken as the guide individuals to attract their surrounding individuals. (iii) e best guide bird (namely, the global best individual) will attract the surrounding ordinary birds and other guide birds. A guide bird will only attract ordinary birds within a certain range. e guide birds do not attract each other (except the best guide bird). e distance between two individuals is calculated as follows: where d is the distance between two individuals, x is an element (weight) of the individual, x ′ is an element (weight) of another individual, and k is an element (weight) number. (iv) An ordinary bird will only be attracted by one guide bird. e distance between the attracted individual and the guide individual is calculated according to (8). e attracted individual can only be attracted by the closest guide individual. e significance of strategies (ii), (iii), and (iv): the guide bird strategy can improve the local search accuracy of the algorithm. e conflict avoidance strategy is used to ensure the stable operation of the algorithm.
(v) Flight and predation of birds: the flight and predation of birds correspond to the running and optimization of the algorithm. All the guide individuals are a group, and the optimization formulas are as follows. Each guide individual and the guided individuals are a group, and the optimization formulas are the same as the former.
where C1 and C2 are weighting coefficients, chrom is the original individual, rand is a random number between 0-1, guichrom is the guide individual, Δchrom is the adjustment amount of the individual, and chrom ′ is the new generated individual. (vi) Obtaining the best bird: set the upper limit of iteration times and run the algorithm. When the iteration times reach the predetermined value, the algorithm stops. e individual which has the highest fitness will be recorded in the entire computation process, and the individual is a group of the best weights of BFNN.

New Weight Adjustment Method.
After the algorithm in the above sections has been completed, a new neuron weight adjustment method is used to continue training the NN. e adjustment formulas of weights between hidden layer and output layer are as follows: where Δw is the adjustment amount of weight, j is the hidden layer number, k is the output layer number, η is the learning rate (it is an empirical value between 0.01-0.5), d is the expected output matrix, y is the actual output matrix, e is the difference matrix between the expected output and the actual output (output layer information), and ΔO j is the difference matrix between the current and previous hidden layer output (hidden layer information). e adjustment formulas of weights between input layer and hidden layer are as follows: where Δw is the adjustment amount of weight, i is the input layer number, j is the hidden layer number, η is the learning rate (it is an empirical value between 0.01-0.5), δ is the local gradient (hidden layer information), ΔO i is the difference matrix between the current and previous input layer output (input layer information), f ′ is used to obtain the derivation of the excitation function, net j is the input of hidden layer, and sqrt is used to obtain the square root of the nonnegative part of a number. e weight calculation formula is as follows:

Online Adjustment of the Number of Hidden Layer
Neurons. After the algorithm of Section 4.3 starts to run, the following method can be used to increase or decrease neurons online.

Method of Increasing Hidden Layer Neuron.
Principle: the initial value of the weight of this NN is a random number which is uniformly distributed between −1 and 1, namely, its absolute value is a random number between 0 and 1. All weights are grouped into four intervals: 0-0.25, 0.25-0.5, 0.5-0.75, and 0.75-1. e number of weights in each interval accounts for about 25%. After many datasets were tested, the following rules were found: when the number of hidden layer neurons is the best, the training will cause most initial weights to be adjusted smaller. When the hidden layer neurons are lacking, the training will cause some weights to be adjusted larger. e above rules can be used to determine if the hidden layer neurons are insufficient.
Concrete operation: after the algorithm of Section4.3 starts to run, determine if the number of weights (greater than 0.75) is greater than 25% (initial ratio). If yes, it means that some neurons are too active, namely, the hidden layer neurons are insufficient, and a hidden layer neuron will be added; if no, the number of neurons is unchanged. e new added weights are set to some small values, and they are uniformly distributed random numbers between −0.1 and 0.1. Continue to train k (100 in this paper) times and repeat the above judgment operation.

Method of Decreasing Hidden Layer Neuron.
Principle: when the number of the hidden layer neurons is the best, after the NN is fully trained, each hidden layer neuron is fully activated, namely, the weight value of each neuron will not be too low. If it is too low (less than 0.001), it means that some neurons are not fully activated and they belong to redundant neurons. e above rules can be used to determine if the hidden layer neurons are excessive.
Concrete operation: after the algorithm of Section 4.3 starts to run, determine if there are neurons whose weight mean is less than 0.001. If yes, these neurons are redundant neurons, and delete a neuron whose weight mean is the lowest; if no, the number of neurons is unchanged. Continue to train k times and repeat the above judgment operation.

Waste Type Identification Method
Based on BFNN e flowchart of waste type recognition algorithm based on BFNN is shown in Figure 5.
e general operation process of the algorithm is as follows: (i) Dataset acquisition: the waste images were analyzed and the feature vectors were extracted (see Section 2). (ii) Feedforward calculation: it includes three parts: determining structure, preprocessing data, and calculating output values (see Section 4.1). (iii) BFO: the BFO was used to learn a known dataset, and the main purpose of the BFO was to find the global optimum (preventing local convergence) (see Section 4.2). (iv) New weight adjustment method: a new weight adjustment method was used to learn data, and the main purpose of this method was to find the local optimum (improving accuracy) (see Section 4.3). (v) Online adjustment method of the number of hidden layer neurons: the hidden layer neurons could be increased and decreased online by this method (see Section 4.4). (vi) Training completed: after the training, the BFNN could identify the types of waste or continue to add data online.

Iteration
Times. e number of training samples of dataset was set to 400. According to the calculation of Section 4.2.1, the initial number of the individuals of BFO was 100. e same number of initial individuals was set to 100, and the same iteration times was set to 100. Run typical GA, typical PSO, and BFO 10 times and obtain the mean, and the experimental results are shown in Figure 6. e data in Figure 6 are the best fitness of each generation. In order to observe easily that the data in Figure 6 are enlarged (×10000), the calculation formula of the fitness of the GA, the PSO, and the BFO is (12).

Mathematical Problems in Engineering
As shown in Figure 7, in terms of iteration times, the BFO has the best fitness after 10 iterations, and the iteration time is less than that of the GA and the PSO. In terms of accuracy, the BFO is slightly better than the PSO and obviously better than the GA.

Recognition Accuracy and Time
Consumption. 400 samples were used to train the BFNN and comparison algorithms. After the training, 200 unknown samples were identified, and each algorithm ran 10 times for obtaining mean value. e experimental results are shown in Table 1.
Here, hidden layer neurons are short for the number of hidden layer neurons.
As shown in Table 1, in terms of recognition accuracy, the recognition accuracy of the BFNN is 81.0%, which is higher than the comparison algorithms and meets the actual needs. In terms of running time, the BFNN is close to the typical GA-BPNN and the typical PSO-BPNN and higher than the BPNN.
On the basis of the above experiments, 200 samples were supplemented online. After training, the NNs would continue identify the types of waste, and each algorithm ran 10 times for obtaining mean value. e experimental results are shown in Table 2.
As shown in Table 2, after the 200 samples have been supplemented online, in terms of recognition accuracy, the recognition accuracy of the BFNN is slightly higher than the former in Table 1, and the BFNN can effectively supply data. In terms of running time, the time consumption of the BFNN is slightly higher than the former in Table 1. In terms of the number of hidden layer neurons, a hidden layer neuron is added online. Table 3, where the sum of each row represents the number of samples of an actual class, and the sum of each column represents the number of samples of a predicted class. Table 3 shows that the recognition effect of cloth is the best and the recognition effect of paper is poor, where some papers were misjudged as plastic. e analysis of the above recognition results is as follows.
As shown in Tables 4 and 5, for each individual image of cloth image (successful), the number of pixels concentrated in a certain color level range is significantly higher than others, namely, the color is relatively monotonous, which is consistent with the intuitive experience of observing    Figure 7. Because the characteristics of cloth images are obvious, the NN has the highest recognition accuracy for cloth.
As shown in Tables 6 and 7, for each individual image of paper image (unsuccessful), the number of pixels concentrated in a certain color level range is significantly higher than others, namely, the color is relatively monotonous. However, the color range of aggregated pixels of the paper images (unsuccessful) is similar to the plastic images, namely, the color of the paper images (unsuccessful) and the plastic images is similar, which is consistent with the intuitive experience of observing Figure 8. Because of the above reasons, the recognition effect of paper by NN is relatively poor, and some papers are misjudged as plastic.

Conclusion
ere are some problems of NN for waste type identification, such as image feature extraction, local optimum, accuracy, and obtaining the number of hidden layer neurons. In this paper, the features of waste images were extracted; a BFO, a new neuron weight adjustment method, and a hidden layer neuron online adjustment method were proposed. e experimental results show that the recyclables (paper, plastic, glass, and cloth) and nonrecyclables can effectively be identified by the waste type identification method based on the BFNN, and the recognition accuracy is 81% which meets actual needs.

Data Availability
e data used to support the findings of this study are available from the corresponding author upon request.

Conflicts of Interest
e authors declare that they have no conflicts of interest.