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

Authors: Shifeng Li; Liyu Chen
Journal: Mathematical Problems in Engineering
 (2020)

---

## Abstract

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. The problem of obtaining the feature dataset of waste images was considered, and color histogram and texture feature extraction techniques were used. The local optimum problem of a typical backpropagation neural network (BPNN) was considered, and a bird flock optimization (BFO) algorithm was proposed. The accuracy problem of the typical BPNN was considered, and a new online weight adjustment method of neurons was proposed. The number of hidden layer neurons (nodes) of the typical BPNN was considered, and an online adjustment method was proposed. The 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.


---

## Body

## 1. Introduction

“Shanghai Household Waste Management Regulation” had been implemented since July 2019. The 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 imaging-based 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. The differential evolution- (DE-) based metaheuristic optimization algorithm was used for optimizing the search space of artificial neural network (ANN), and the effect of ANN-DE-based 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]. The 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 ﬂyrock 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–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–17]. There 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.


## 2. Dataset Acquisition

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


### 2.1. Obtaining Input Data

The images of some waste are shown in Figure1.Figure 1
Images of waste: (a) paper; (b) plastic; (c) cloth; (d) nonrecyclables.The image features in Figure1 were extracted to generate dataset, and the dataset was used as the input data of NN.


#### 2.1.1. Extracting Feature Information of Color Histogram of Image

The 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. The 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.The tricolor histogram of Figure1(d) is shown in Figure 2.Figure 2
Tricolor histogram: (a) red component; (b) green component; (c) blue component.In Figure2, the abscissa is the pixel level, and the ordinate is the number of pixels.The number of 0–50 colored pixels of the red component histogram was captured as feature vector 1. The number of 51–100 colored pixels of the red component histogram was captured as feature vector 2. The number of 101–150 colored pixels of the red component histogram was captured as feature vector 3. The number of 151–200 colored pixels of the red component histogram was captured as feature vector 4. The number of 201–255 colored pixels of the red component histogram was captured as feature vector 5.The extraction method of the feature vectors of green component and blue component was the same as the red component. A total of 15 feature vectors were generated.


#### 2.1.2. Extracting Feature Information of Texture of Image

The surface properties of images and corresponding objects are described by texture features. Three texture feature vectors including mean, contrast, and entropy were used in this paper.Letx,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:(1)Δgx,y=gx,y−gx+Δx,y+Δy.The calculation formulas of mean, contrast, and entropy are as follows [21]:(2)mean=1m∑iipi,con=∑ii2pi,entropy=−∑ipilog2pi,where mean is the average value, m is the number of gray level, i is the gray level number, pi is the probability of Δgx,y, con is the contrast value, and entropy is the entropy value.The input of NN includes 15 color histogram feature vectors and 3 texture feature vectors and a total of 18 feature vectors.


### 2.2. 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. Therefore, 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. The corresponding output of NN was in the order of 00001, 00010, 00100, 01000, and 10000.


## 2.1. Obtaining Input Data

The images of some waste are shown in Figure1.Figure 1
Images of waste: (a) paper; (b) plastic; (c) cloth; (d) nonrecyclables.The image features in Figure1 were extracted to generate dataset, and the dataset was used as the input data of NN.


### 2.1.1. Extracting Feature Information of Color Histogram of Image

The 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. The 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.The tricolor histogram of Figure1(d) is shown in Figure 2.Figure 2
Tricolor histogram: (a) red component; (b) green component; (c) blue component.In Figure2, the abscissa is the pixel level, and the ordinate is the number of pixels.The number of 0–50 colored pixels of the red component histogram was captured as feature vector 1. The number of 51–100 colored pixels of the red component histogram was captured as feature vector 2. The number of 101–150 colored pixels of the red component histogram was captured as feature vector 3. The number of 151–200 colored pixels of the red component histogram was captured as feature vector 4. The number of 201–255 colored pixels of the red component histogram was captured as feature vector 5.The extraction method of the feature vectors of green component and blue component was the same as the red component. A total of 15 feature vectors were generated.


### 2.1.2. Extracting Feature Information of Texture of Image

The surface properties of images and corresponding objects are described by texture features. Three texture feature vectors including mean, contrast, and entropy were used in this paper.Letx,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:(1)Δgx,y=gx,y−gx+Δx,y+Δy.The calculation formulas of mean, contrast, and entropy are as follows [21]:(2)mean=1m∑iipi,con=∑ii2pi,entropy=−∑ipilog2pi,where mean is the average value, m is the number of gray level, i is the gray level number, pi is the probability of Δgx,y, con is the contrast value, and entropy is the entropy value.The input of NN includes 15 color histogram feature vectors and 3 texture feature vectors and a total of 18 feature vectors.


## 2.1.1. Extracting Feature Information of Color Histogram of Image

The 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. The 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.The tricolor histogram of Figure1(d) is shown in Figure 2.Figure 2
Tricolor histogram: (a) red component; (b) green component; (c) blue component.In Figure2, the abscissa is the pixel level, and the ordinate is the number of pixels.The number of 0–50 colored pixels of the red component histogram was captured as feature vector 1. The number of 51–100 colored pixels of the red component histogram was captured as feature vector 2. The number of 101–150 colored pixels of the red component histogram was captured as feature vector 3. The number of 151–200 colored pixels of the red component histogram was captured as feature vector 4. The number of 201–255 colored pixels of the red component histogram was captured as feature vector 5.The extraction method of the feature vectors of green component and blue component was the same as the red component. A total of 15 feature vectors were generated.


## 2.1.2. Extracting Feature Information of Texture of Image

The surface properties of images and corresponding objects are described by texture features. Three texture feature vectors including mean, contrast, and entropy were used in this paper.Letx,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:(1)Δgx,y=gx,y−gx+Δx,y+Δy.The calculation formulas of mean, contrast, and entropy are as follows [21]:(2)mean=1m∑iipi,con=∑ii2pi,entropy=−∑ipilog2pi,where mean is the average value, m is the number of gray level, i is the gray level number, pi is the probability of Δgx,y, con is the contrast value, and entropy is the entropy value.The input of NN includes 15 color histogram feature vectors and 3 texture feature vectors and a total of 18 feature vectors.


## 2.2. 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. Therefore, 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. The corresponding output of NN was in the order of 00001, 00010, 00100, 01000, and 10000.


## 3. Differences between BFNN and Typical BPNN

The structure of a BFNN is shown in Figure3.Figure 3
Structure of BFNN.There are some characteristics of the BFNN in Figure3. The network consists of at least three layers. The 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.The main differences between BFNN and typical BPNN are as follows.


### 3.1. A Bird Flock Algorithm

The bird flock optimization (BFO) algorithm is an intelligent optimization algorithm proposed in this paper, which will be compared with PSO [22, 23].The differences between BFO and PSO are as follows:(i)
PSO. Each individual emulates its most successful neighbor by updating its velocity and position to follow the most successful position of neighbors for global search [24].(ii)
BFO. The BFO is proposed by imitating the process of bird flock seeking food.Biological foundation: the process of bird flock seeking food.The 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.


### 3.2. A New Weight Adjustment Method of Neurons

The differences between the weight adjustment method of BFNN and typical BPNN are as follows:(i)
Typical BPNN. The 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.The 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.


### 3.3. An Online Adjustment Method of the Number of Hidden Layer Neurons

The differences between the adjustment method of the number of the hidden layer of BFNN and typical BPNN are as follows:(i)
Typical BPNN. The 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. The 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.The purpose of this operation: the BFNN can increase or decrease the number of the hidden layer neurons online after the adjustment method is used.


## 3.1. A Bird Flock Algorithm

The bird flock optimization (BFO) algorithm is an intelligent optimization algorithm proposed in this paper, which will be compared with PSO [22, 23].The differences between BFO and PSO are as follows:(i)
PSO. Each individual emulates its most successful neighbor by updating its velocity and position to follow the most successful position of neighbors for global search [24].(ii)
BFO. The BFO is proposed by imitating the process of bird flock seeking food.Biological foundation: the process of bird flock seeking food.The 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.


## 3.2. A New Weight Adjustment Method of Neurons

The differences between the weight adjustment method of BFNN and typical BPNN are as follows:(i)
Typical BPNN. The 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.The 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.


## 3.3. An Online Adjustment Method of the Number of Hidden Layer Neurons

The differences between the adjustment method of the number of the hidden layer of BFNN and typical BPNN are as follows:(i)
Typical BPNN. The 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. The 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.The purpose of this operation: the BFNN can increase or decrease the number of the hidden layer neurons online after the adjustment method is used.


## 4. Principle of BFNN

### 4.1. Feedforward Calculation

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


#### 4.1.1. Determining Structure

The number of input and output layer neurons was manually determined on the basis of dataset information.The calculation formulas of the number of initial hidden layer neurons are as follows:(3)l1=m−1,l2=m+n+5,l3=log2m,l=l1+l2+l33,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.


#### 4.1.2. Preprocessing Data

The dataset is normalized, and the calculation formula is as follows:(4)x′=x−xminxmax−xmin,where x is the original data, x′ is the normalized data, xmax is the maximum value of x,andxmin is the minimum value of x.The normalized dataset was divided into four parts: training input, training output, test input, and test output.


#### 4.1.3. Calculating Output Values

LetO1k,O2k,…,Omk be the NN input, namely, Oik, where i is the input layer neuron number. For the convenience of writing, the sample number is omitted. The input data pass through the hidden layer to the output layer. The input of hidden layer is netjk=∑i=1mwijkOik, where wij is the weight between input layer and hidden layer. The output of hidden layer is Ojk=fnetjk, where f is excitation function and j is the hidden layer neuron number. The excitation function is a hyperbolic tangent function, and the calculation formula is y=2/1+e−2x−1. The input of output layer is netkk=∑j=1qwjkkOjk, where q is the hidden layer neuron number and k is the output layer neuron number. The output layer excitation function is a linear excitation function, and the output of output layer neurons is Ok=netk.


### 4.2. 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 toSection 4.3.The algorithm flow of the BFO is shown in Figure4.Figure 4
Flowchart of BFO.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. The predation effect is fitness. Flight times are the iteration times of BFO. Surrounding birds are the individuals within a certain distance. The overall predation effect of bird flock is average fitness.The principle of BFO is as follows.


#### 4.2.1. Generating the Number of Initial Birds

The 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. The 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 thresholdb1 in the graph, and the number of the peaks is denoted by peaknumi. Set the threshold b2; if peaknumi>b2, then classnumi=peaknumi; if peaknumi<b2, then classnumi=1. Calculate tclassnum based on (10).(5)tclassnum=∏i=1Mclassnumi,where tclassnum is the number of classes of dataset and classnumi is the number of classes on the i-th input vector of dataset.The calculation formula of the initial bird flock is as follows:(6)ininum=∏i=1Mclassnumi2/M,where ininum is an integer between 10 and 200, and it is an integer multiple of 10.


#### 4.2.2. Bird Flock Search Strategy

The bird flock search strategy is as follows:(i)
The birds which have better predation effect stay, and the birds which have poorer predation effect fly away. The 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:(7)fit=∑1avalue−pvalue,where fit is the fitness of individual, avalue is the actual value of output, and pvalue is the predicted value of output.The average fitness,meanfit, is calculated after running the algorithm. The 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. The value of weights are rounded, and they are kept one decimal place. After the above 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. The above operation ensures that the new individual does not appear within a certain range of the old individual. This operation needs to set the upper limit of reset times (2 in this paper) to prevent an endless loop.The 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. This 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. The guide birds will attract nearby birds to search a smaller area together.Theininum individuals are sorted from high to low based on the fitness. The first 20% individuals are taken as the guide individuals to attract their surrounding individuals.(iii)
The 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. The guide birds do not attract each other (except the best guide bird).The distance between two individuals is calculated as follows:(8)d=x1−x1′2+⋯+xk−xk′2,whered 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. The distance between the attracted individual and the guide individual is calculated according to(8). The attracted individual can only be attracted by the closest guide individual.The significance of strategies (ii), (iii), and (iv): the guide bird strategy can improve the local search accuracy of the algorithm. The 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.(9)x1=C1⋅chrom,x2=C2⋅rand⋅guichrom−chrom,Δchrom=x1+x2,chrom′=chrom+Δchrom,whereC1 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.The 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.


### 4.3. 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.The adjustment formulas of weights between hidden layer and output layer are as follows:(10)Δwjkk=η⋅sqrtek⋅ΔOjk,ek=dk−yk,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 ΔOj is the difference matrix between the current and previous hidden layer output (hidden layer information).The adjustment formulas of weights between input layer and hidden layer are as follows:(11)Δwijk=η⋅sqrtδjk⋅ΔOik,δjk=∑k=1Lekwjkkf′netjk,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), ΔOi 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, netj is the input of hidden layer, and sqrt is used to obtain the square root of the nonnegative part of a number.The weight calculation formula is as follows:(12)wk=wk−1+Δwk.


### 4.4. Online Adjustment of the Number of Hidden Layer Neurons

After the algorithm ofSection 4.3 starts to run, the following method can be used to increase or decrease neurons online.


#### 4.4.1. 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. The 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.The above rules can be used to determine if the hidden layer neurons are insufficient.Concrete operation: after the algorithm ofSection4.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. The 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.


#### 4.4.2. 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.The above rules can be used to determine if the hidden layer neurons are excessive.Concrete operation: after the algorithm ofSection 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.


## 4.1. Feedforward Calculation

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


### 4.1.1. Determining Structure

The number of input and output layer neurons was manually determined on the basis of dataset information.The calculation formulas of the number of initial hidden layer neurons are as follows:(3)l1=m−1,l2=m+n+5,l3=log2m,l=l1+l2+l33,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.


### 4.1.2. Preprocessing Data

The dataset is normalized, and the calculation formula is as follows:(4)x′=x−xminxmax−xmin,where x is the original data, x′ is the normalized data, xmax is the maximum value of x,andxmin is the minimum value of x.The normalized dataset was divided into four parts: training input, training output, test input, and test output.


### 4.1.3. Calculating Output Values

LetO1k,O2k,…,Omk be the NN input, namely, Oik, where i is the input layer neuron number. For the convenience of writing, the sample number is omitted. The input data pass through the hidden layer to the output layer. The input of hidden layer is netjk=∑i=1mwijkOik, where wij is the weight between input layer and hidden layer. The output of hidden layer is Ojk=fnetjk, where f is excitation function and j is the hidden layer neuron number. The excitation function is a hyperbolic tangent function, and the calculation formula is y=2/1+e−2x−1. The input of output layer is netkk=∑j=1qwjkkOjk, where q is the hidden layer neuron number and k is the output layer neuron number. The output layer excitation function is a linear excitation function, and the output of output layer neurons is Ok=netk.


## 4.1.1. Determining Structure

The number of input and output layer neurons was manually determined on the basis of dataset information.The calculation formulas of the number of initial hidden layer neurons are as follows:(3)l1=m−1,l2=m+n+5,l3=log2m,l=l1+l2+l33,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.


## 4.1.2. Preprocessing Data

The dataset is normalized, and the calculation formula is as follows:(4)x′=x−xminxmax−xmin,where x is the original data, x′ is the normalized data, xmax is the maximum value of x,andxmin is the minimum value of x.The normalized dataset was divided into four parts: training input, training output, test input, and test output.


## 4.1.3. Calculating Output Values

LetO1k,O2k,…,Omk be the NN input, namely, Oik, where i is the input layer neuron number. For the convenience of writing, the sample number is omitted. The input data pass through the hidden layer to the output layer. The input of hidden layer is netjk=∑i=1mwijkOik, where wij is the weight between input layer and hidden layer. The output of hidden layer is Ojk=fnetjk, where f is excitation function and j is the hidden layer neuron number. The excitation function is a hyperbolic tangent function, and the calculation formula is y=2/1+e−2x−1. The input of output layer is netkk=∑j=1qwjkkOjk, where q is the hidden layer neuron number and k is the output layer neuron number. The output layer excitation function is a linear excitation function, and the output of output layer neurons is Ok=netk.


## 4.2. 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 toSection 4.3.The algorithm flow of the BFO is shown in Figure4.Figure 4
Flowchart of BFO.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. The predation effect is fitness. Flight times are the iteration times of BFO. Surrounding birds are the individuals within a certain distance. The overall predation effect of bird flock is average fitness.The principle of BFO is as follows.


### 4.2.1. Generating the Number of Initial Birds

The 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. The 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 thresholdb1 in the graph, and the number of the peaks is denoted by peaknumi. Set the threshold b2; if peaknumi>b2, then classnumi=peaknumi; if peaknumi<b2, then classnumi=1. Calculate tclassnum based on (10).(5)tclassnum=∏i=1Mclassnumi,where tclassnum is the number of classes of dataset and classnumi is the number of classes on the i-th input vector of dataset.The calculation formula of the initial bird flock is as follows:(6)ininum=∏i=1Mclassnumi2/M,where ininum is an integer between 10 and 200, and it is an integer multiple of 10.


### 4.2.2. Bird Flock Search Strategy

The bird flock search strategy is as follows:(i)
The birds which have better predation effect stay, and the birds which have poorer predation effect fly away. The 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:(7)fit=∑1avalue−pvalue,where fit is the fitness of individual, avalue is the actual value of output, and pvalue is the predicted value of output.The average fitness,meanfit, is calculated after running the algorithm. The 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. The value of weights are rounded, and they are kept one decimal place. After the above 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. The above operation ensures that the new individual does not appear within a certain range of the old individual. This operation needs to set the upper limit of reset times (2 in this paper) to prevent an endless loop.The 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. This 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. The guide birds will attract nearby birds to search a smaller area together.Theininum individuals are sorted from high to low based on the fitness. The first 20% individuals are taken as the guide individuals to attract their surrounding individuals.(iii)
The 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. The guide birds do not attract each other (except the best guide bird).The distance between two individuals is calculated as follows:(8)d=x1−x1′2+⋯+xk−xk′2,whered 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. The distance between the attracted individual and the guide individual is calculated according to(8). The attracted individual can only be attracted by the closest guide individual.The significance of strategies (ii), (iii), and (iv): the guide bird strategy can improve the local search accuracy of the algorithm. The 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.(9)x1=C1⋅chrom,x2=C2⋅rand⋅guichrom−chrom,Δchrom=x1+x2,chrom′=chrom+Δchrom,whereC1 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.The 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.


## 4.2.1. Generating the Number of Initial Birds

The 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. The 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 thresholdb1 in the graph, and the number of the peaks is denoted by peaknumi. Set the threshold b2; if peaknumi>b2, then classnumi=peaknumi; if peaknumi<b2, then classnumi=1. Calculate tclassnum based on (10).(5)tclassnum=∏i=1Mclassnumi,where tclassnum is the number of classes of dataset and classnumi is the number of classes on the i-th input vector of dataset.The calculation formula of the initial bird flock is as follows:(6)ininum=∏i=1Mclassnumi2/M,where ininum is an integer between 10 and 200, and it is an integer multiple of 10.


## 4.2.2. Bird Flock Search Strategy

The bird flock search strategy is as follows:(i)
The birds which have better predation effect stay, and the birds which have poorer predation effect fly away. The 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:(7)fit=∑1avalue−pvalue,where fit is the fitness of individual, avalue is the actual value of output, and pvalue is the predicted value of output.The average fitness,meanfit, is calculated after running the algorithm. The 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. The value of weights are rounded, and they are kept one decimal place. After the above 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. The above operation ensures that the new individual does not appear within a certain range of the old individual. This operation needs to set the upper limit of reset times (2 in this paper) to prevent an endless loop.The 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. This 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. The guide birds will attract nearby birds to search a smaller area together.Theininum individuals are sorted from high to low based on the fitness. The first 20% individuals are taken as the guide individuals to attract their surrounding individuals.(iii)
The 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. The guide birds do not attract each other (except the best guide bird).The distance between two individuals is calculated as follows:(8)d=x1−x1′2+⋯+xk−xk′2,whered 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. The distance between the attracted individual and the guide individual is calculated according to(8). The attracted individual can only be attracted by the closest guide individual.The significance of strategies (ii), (iii), and (iv): the guide bird strategy can improve the local search accuracy of the algorithm. The 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.(9)x1=C1⋅chrom,x2=C2⋅rand⋅guichrom−chrom,Δchrom=x1+x2,chrom′=chrom+Δchrom,whereC1 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.The 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.


## 4.3. 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.The adjustment formulas of weights between hidden layer and output layer are as follows:(10)Δwjkk=η⋅sqrtek⋅ΔOjk,ek=dk−yk,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 ΔOj is the difference matrix between the current and previous hidden layer output (hidden layer information).The adjustment formulas of weights between input layer and hidden layer are as follows:(11)Δwijk=η⋅sqrtδjk⋅ΔOik,δjk=∑k=1Lekwjkkf′netjk,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), ΔOi 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, netj is the input of hidden layer, and sqrt is used to obtain the square root of the nonnegative part of a number.The weight calculation formula is as follows:(12)wk=wk−1+Δwk.


## 4.4. Online Adjustment of the Number of Hidden Layer Neurons

After the algorithm ofSection 4.3 starts to run, the following method can be used to increase or decrease neurons online.


### 4.4.1. 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. The 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.The above rules can be used to determine if the hidden layer neurons are insufficient.Concrete operation: after the algorithm ofSection4.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. The 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.


### 4.4.2. 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.The above rules can be used to determine if the hidden layer neurons are excessive.Concrete operation: after the algorithm ofSection 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.


## 4.4.1. 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. The 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.The above rules can be used to determine if the hidden layer neurons are insufficient.Concrete operation: after the algorithm ofSection4.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. The 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.


## 4.4.2. 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.The above rules can be used to determine if the hidden layer neurons are excessive.Concrete operation: after the algorithm ofSection 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.


## 5. Waste Type Identification Method Based on BFNN

The flowchart of waste type recognition algorithm based on BFNN is shown in Figure5.Figure 5
Flowchart of waste type recognition algorithm based on BFNN.The general operation process of the algorithm is as follows:(i)
Dataset acquisition: the waste images were analyzed and the feature vectors were extracted (see Section2).(ii)
Feedforward calculation: it includes three parts: determining structure, preprocessing data, and calculating output values (see Section4.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) (seeSection 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) (seeSection 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 (seeSection 4.4).(vi)
Training completed: after the training, the BFNN could identify the types of waste or continue to add data online.


## 6. Experimental Verification and Result Analysis

### 6.1. Iteration Times

The number of training samples of dataset was set to 400. According to the calculation of Section4.2.1, the initial number of the individuals of BFO was 100.The 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 Figure6.Figure 6
Comparison of iterative effects of different algorithms.The data in Figure6 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).As shown in Figure7, 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.Figure 7
Some successful recognition result images of cloth.


### 6.2. 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. The experimental results are shown in Table1.Table 1
Comparison of recognition results after 400 samples are used.
Hidden layer neuronsRecognition accuracyTime consumptionPaper (%)Plastic (%)Glass (%)Cloth (%)NonrecyclablesTotalBPNN1080.944.447.952.379.460.81.25GA-BPNN1072.532.854.061.966.961.42.70PSO-BPNN1081.958.543.061.477.064.22.64BFNN1187.677.272.984.485.381.43.41Here, hidden layer neurons are short for the number of hidden layer neurons.As shown in Table1, 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. The experimental results are shown in Table2.Table 2
Comparison of recognition results after 200 samples are supplemented online.
Hidden layer neuronsRecognition accuracyTime consumption (s)Paper (%)Plastic (%)Glass (%)Cloth (%)Nonrecyclables (%)Total (%)BPNN1074.847.344.956.972.060.11.12GA-BPNN1073.027.860.562.169.458.82.57PSO-BPNN1081.441.655.458.267.460.92.50BFNN1087.676.972.084.585.381.02.83As shown in Table2, 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.


### 6.3. Confusion Matrix

A confusion matrix for the best case of BFNN is shown in Table3, 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
Confusion matrix for waste identification.
Predicted classClothPaperPlasticGlassNonrecyclablesActual classCloth300102Paper0271110Plastic024042Glass010325Nonrecyclables024036Table3 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. The analysis of the above recognition results is as follows.


#### 6.3.1. Some Successful Recognition Result Images and Analysis

Some successful recognition result images of cloth are shown in Figure7.The feature information of Figure7 is shown in Tables 4 and 5, where these numbers (1–15) are characteristic information number (see Section 2.1 for details).Table 4
The feature information (1–8) of Figure7.
Input feature vector number of NN12345678Figure7(a)016072255038424189642665573Figure7(b)01589659197051047801059443Figure7(c)852510411202188838233810133Figure7(d)1711110644822174010961111417135011Table 5
The feature information (9–15) of Figure7.
Input feature vector number of NN9101112131415Figure7(a)20419784615557876376258121870Figure7(b)2029510157303143776571233462675Figure7(c)210078520146047367492208935419Figure7(d)21060111023327605554281403513As shown in Tables4 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.


#### 6.3.2. Some Unsuccessful Recognition Result Images and Analysis

Some unsuccessful recognition result images of paper and comparison images are shown in Figure8.Figure 8
Some unsuccessful recognition result images of paper and comparison images: (a) toilet paper; (b) toilet paper; (c) white plastic gears; (d) packaging plastic.The feature information of Figure8 is shown in Tables 6 and 7, where these numbers (1–15) are characteristic information number (see Section 2.1 for details).Table 6
The feature information (1–8) of Figure8.
Input feature vector number of NN12345678Figure8(a)01151144782477100149414415Figure8(b)01467160132252000169116634Figure8(c)0288794382766870319110972Figure8(d)086512251266192650101512213Table 7
The feature information (9–15) of Figure8.
Input feature vector number of NN9101112131415Figure8(a)2408830163416705216610Figure8(b)2167500170418901193950Figure8(c)2583250316615647211870Figure8(d)2649228007421441624671171As shown in Tables6 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.


## 6.1. Iteration Times

The number of training samples of dataset was set to 400. According to the calculation of Section4.2.1, the initial number of the individuals of BFO was 100.The 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 Figure6.Figure 6
Comparison of iterative effects of different algorithms.The data in Figure6 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).As shown in Figure7, 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.Figure 7
Some successful recognition result images of cloth.


## 6.2. 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. The experimental results are shown in Table1.Table 1
Comparison of recognition results after 400 samples are used.
Hidden layer neuronsRecognition accuracyTime consumptionPaper (%)Plastic (%)Glass (%)Cloth (%)NonrecyclablesTotalBPNN1080.944.447.952.379.460.81.25GA-BPNN1072.532.854.061.966.961.42.70PSO-BPNN1081.958.543.061.477.064.22.64BFNN1187.677.272.984.485.381.43.41Here, hidden layer neurons are short for the number of hidden layer neurons.As shown in Table1, 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. The experimental results are shown in Table2.Table 2
Comparison of recognition results after 200 samples are supplemented online.
Hidden layer neuronsRecognition accuracyTime consumption (s)Paper (%)Plastic (%)Glass (%)Cloth (%)Nonrecyclables (%)Total (%)BPNN1074.847.344.956.972.060.11.12GA-BPNN1073.027.860.562.169.458.82.57PSO-BPNN1081.441.655.458.267.460.92.50BFNN1087.676.972.084.585.381.02.83As shown in Table2, 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.


## 6.3. Confusion Matrix

A confusion matrix for the best case of BFNN is shown in Table3, 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
Confusion matrix for waste identification.
Predicted classClothPaperPlasticGlassNonrecyclablesActual classCloth300102Paper0271110Plastic024042Glass010325Nonrecyclables024036Table3 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. The analysis of the above recognition results is as follows.


### 6.3.1. Some Successful Recognition Result Images and Analysis

Some successful recognition result images of cloth are shown in Figure7.The feature information of Figure7 is shown in Tables 4 and 5, where these numbers (1–15) are characteristic information number (see Section 2.1 for details).Table 4
The feature information (1–8) of Figure7.
Input feature vector number of NN12345678Figure7(a)016072255038424189642665573Figure7(b)01589659197051047801059443Figure7(c)852510411202188838233810133Figure7(d)1711110644822174010961111417135011Table 5
The feature information (9–15) of Figure7.
Input feature vector number of NN9101112131415Figure7(a)20419784615557876376258121870Figure7(b)2029510157303143776571233462675Figure7(c)210078520146047367492208935419Figure7(d)21060111023327605554281403513As shown in Tables4 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.


### 6.3.2. Some Unsuccessful Recognition Result Images and Analysis

Some unsuccessful recognition result images of paper and comparison images are shown in Figure8.Figure 8
Some unsuccessful recognition result images of paper and comparison images: (a) toilet paper; (b) toilet paper; (c) white plastic gears; (d) packaging plastic.The feature information of Figure8 is shown in Tables 6 and 7, where these numbers (1–15) are characteristic information number (see Section 2.1 for details).Table 6
The feature information (1–8) of Figure8.
Input feature vector number of NN12345678Figure8(a)01151144782477100149414415Figure8(b)01467160132252000169116634Figure8(c)0288794382766870319110972Figure8(d)086512251266192650101512213Table 7
The feature information (9–15) of Figure8.
Input feature vector number of NN9101112131415Figure8(a)2408830163416705216610Figure8(b)2167500170418901193950Figure8(c)2583250316615647211870Figure8(d)2649228007421441624671171As shown in Tables6 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.


## 6.3.1. Some Successful Recognition Result Images and Analysis

Some successful recognition result images of cloth are shown in Figure7.The feature information of Figure7 is shown in Tables 4 and 5, where these numbers (1–15) are characteristic information number (see Section 2.1 for details).Table 4
The feature information (1–8) of Figure7.
Input feature vector number of NN12345678Figure7(a)016072255038424189642665573Figure7(b)01589659197051047801059443Figure7(c)852510411202188838233810133Figure7(d)1711110644822174010961111417135011Table 5
The feature information (9–15) of Figure7.
Input feature vector number of NN9101112131415Figure7(a)20419784615557876376258121870Figure7(b)2029510157303143776571233462675Figure7(c)210078520146047367492208935419Figure7(d)21060111023327605554281403513As shown in Tables4 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.


## 6.3.2. Some Unsuccessful Recognition Result Images and Analysis

Some unsuccessful recognition result images of paper and comparison images are shown in Figure8.Figure 8
Some unsuccessful recognition result images of paper and comparison images: (a) toilet paper; (b) toilet paper; (c) white plastic gears; (d) packaging plastic.The feature information of Figure8 is shown in Tables 6 and 7, where these numbers (1–15) are characteristic information number (see Section 2.1 for details).Table 6
The feature information (1–8) of Figure8.
Input feature vector number of NN12345678Figure8(a)01151144782477100149414415Figure8(b)01467160132252000169116634Figure8(c)0288794382766870319110972Figure8(d)086512251266192650101512213Table 7
The feature information (9–15) of Figure8.
Input feature vector number of NN9101112131415Figure8(a)2408830163416705216610Figure8(b)2167500170418901193950Figure8(c)2583250316615647211870Figure8(d)2649228007421441624671171As shown in Tables6 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.


## 7. Conclusion

There 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. The 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.



---

*Source: 9214350-2020-08-25.xml*