{'fraction_non_alphanumeric': 0.030496592015579357, 'fraction_numerical': 0.008549172346640701, 'mean_word_length': 4.968270571827057, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Structure and Performance of Fully Connected Neural Networks: Emerging Complex Network Properties

Understanding the behavior of Artificial Neural Networks is one of the main topics in the field recently, as black-box approaches have become usual since the widespread of deep learning. Such high-dimensional models may manifest instabilities and weird properties that resemble complex systems. Therefore, we propose Complex Network (CN) techniques to analyze the structure and performance of fully connected neural networks. For that, we build a dataset with 4 thousand models and their respective CN properties. They are employed in a supervised classification setup considering four vision benchmarks. Each neural network is approached as a weighted and undirected graph of neurons and synapses, and centrality measures are computed after training. Results show that these measures are highly related to the network classification performance. We also propose the concept of Bag-Of-Neurons (BoN), a CN-based approach for finding topological signatures linking similar neurons. Results suggest that six neuronal types emerge in such networks, independently of the target domain, and are distributed differently according to classification accuracy. We also tackle specific CN properties related to performance, such as higher subgraph centrality on lower-performing models. Our findings suggest that CN properties play a critical role in the performance of fully connected neural networks, with topological patterns emerging independently on a wide range of models.


Introduction
Artificial Neural Networks (ANN) are in a non-stopping ascension since the introduction of deep learning, and many successful applications have been developed [1]. The state-of-the-art on various applications is constantly pushed forward by innovative neural architectures, training mechanisms, and big data collections. The fast advances in these techniques and hardware technology make it possible to create deeper and more complex models. However, this phenomenon leads to black-box approaches becoming usual in many applications, as the study of ANN fundamentals does not follow the same rhythm. For instance, the lack of understanding of its internal details [2] causes some intriguing inexplicable properties to be observed in deep convolutional networks [3], one of the most popular ANN architectures for Computer Vision. Experiments have shown that imperceptible input perturbations can drastically impact performance, a phenomenon also known as adversarial examples [4]. It is also possible to create entirely unrecognizable images, but that convolutional networks strongly believe are recognizable objects [3]. These performance instabilities limits research not only on neural network functioning, but also on network optimization such as better synapse initialization, construction, architecture search, and improved fitting mechanisms. Improving our knowledge of their properties will then lead to Explainable Artificial Intelligence (XAI) [5] and also more robust and accurate models. Therefore, understanding the functioning of ANNs is recently one of the main topics within the field, which has become a true interdisciplinary research uniting computer scientists with neuroscientists, psychologists, mathematicians and physicists.
Some of the weird behaviors observed on ANNs are compatible with complex systems, which are usually non-linear, hard to predict, and sometimes sensitive to small perturbations. One interesting approach then to study such systems is through Complex Networks (CN), or Network Science, a research field that emerges from graph theory, physics, and statistics. Its main goal is to study large networks derived from natural, complex processes, which correlate to various neural networks such as biological ones. For instance, it was shown the existence of the small-world CN phenomenon in the neural network of the Caenorhabditis elegans worm [6]. Various works then found such topological patterns also in human neural networks, like from magnetoencephalography recordings [7], analysis of cortical connections [8] and of the brain stem medial reticular formation [9]. In this context, CN principles have helped to understand the origin of dynamic brain activity in anatomical circuits at various levels of scale [10].
In the case of ANN, few works have approached them from CN principles. In [11], Hopfield networks are simulated as scale-free CNs, reducing the number of neuron connections and reducing the size and computational cost while keeping tolerable performance. A work from 2004 [12] shows that attractor networks with scale-free topology have a greater capacity to store and retrieve binary patterns than highly random Hopfield networks with the same number of synapses. The relative performance of the scale-free system increases with increasing values of its power-law exponent. More recently (2016) [13] and after the deep learning diffusion, authors proposed a small-world ANN that has better performance than traditional structure in the task of a diabetes diagnosis. In a 2020 work [14], CNs are employed for the analysis of 5-layer deep-belief networks, and results suggest correlations between topological properties and functioning. Another 2020 work [15] explores the emergence of network motifs, i.e., a group of neurons with a distinct connection pattern, on a small Multilayer Perceptron (MLP) ANN. They considered different number of neurons on this architecture applied on small synthetic data, and concludes that specific motifs emerge during training. In a 2021 work [16], CNs were used to analyze the output of convolutional neural networks in texture images. This work also corroborates with the existence of CN information within ANNs, which they consider for enhancing the model's classification power for texture analysis.
Although these works suggest CN properties within ANNs, much still needs to be done to uncover its properties. Moreover, these works do not consider a reliable number of neural networks to account for the wide possible states of random synapse organizations. It is widely known that different weight initialization can cause drastic changes in neural network behavior, such as some specific distributions which may make training particularly effective [17].
The present work approaches fully connected multilayer neural networks as CNs, focusing on neuronal topological properties. We considered deep MLP-like networks applied for supervised classification on vision tasks, which is also one of the most diffused ANN areas. Our analysis consider a large neural network population (4 thousand models), with different initial synapses, trained on four vision benchmarks, which we make available as a new dataset for studying ANNs 1 . They are characterized through CN centrality measures computed from its hidden neurons, which are also available in the repository. The following sections of the paper are divided by: Section 2 gives the background fundamentals on ANNs and CNs; Section 3 describe the proposed methodology for building the neural network dataset and analyzing it through CNs; Section 4 shows and discuss our analyzes and obtained results; and finally, Section 5 concludes the work with the overall findings, the most critical remarks, and future works.

Theoretical Background
This section introduces the fundamentals of ANNs and CNs, focusing on models and techniques employed in this work.

Artificial Neural Networks
After the first neuroscience discoveries about the brain, scientists started to study artificial models. Around 1943, from the work "A logical calculus of the ideas immanent in nervous tissue" [18], the first ideas of artificial neurons are established. In 1958, Rosenblatt introduced the Perceptron [19], the first artificial neuron capable of performing pattern recognition tasks after training. It can be defined as a function φ( X) = y, which computes b + x i w i , where w i are learnable weights and x i are input elements of X. The neuron's output results from its activation function φ, which is the Heaviside step function (threshold function) that returns 1 if y > 1, and 0 otherwise. The training process consists of adjusting each weight w i in a supervised fashion, i.e., the desired output is known for the training set. Given a training sample, the new weight is adjusted by whereȳ is the expected output for the input vector X and α is the learning rate, that controls the update magnitude. By iterative repeating this process for e epochs in a given training set, the Perceptron tends to find a solution for a binary problem if it is linearly separable.
ANNs, in turn, are composed of a chain of connected neurons usually organized in d layers. Theoretically, a network extensive enough could fit any function, which is one reason for attracting the scientific community's attention. One of the most traditional ANN models is the MLP [20], usually composed of d = 3 layers: input, hidden layer, and output. These layers are fully connected with the next and previous layers, and no connections exist between neurons of the same layer. A layer can be represented by a matrix W a+1 ij that describes the weights of connections between the i neurons of layer a with the j neurons of layer a + 1. The output of a layer is then computed by matrix operations where Y is a vector with the output of each layer's neurons. The activation function φ is usually a non-linear operator. The process is then repeated to each of the d layers, using the output of the previous layer ( Y a−1 ) as input to the next one, multiplying to the corresponding weights φ( Y a−1 · W a ) = Y a , where j and l are neuron indices from layer a − 1 and a. At the last layer, the final output Y d is obtained by a different activation function φ, corresponding to the problem one needs to address (e.g., linear for binary classification, or softmax for multiclass tasks). The whole model can then be approached as a collection of layers ℵ = {L 0 , ..., L d }, each one with a set of associated weights W , and an activation function φ. Between the decades of 1970 and 1980 [21] advances on these networks' training through backpropagation helped consolidate the multilayer approach. In most cases of supervised classification this training technique is prevalent until today and consists of propagating the last layer's error ( Y d − X) backward, updating weight matrices W a layer-by-layer similarly to the Perceptron approach.
Although the theory behind fully connected networks supports an ideal pattern recognizer hypothesis, its performance remained similar to other statistical and logical methods between 1990 and 2000. This stagnation happened due to the lack of efficient training techniques for deeper and larger networks. This training approach, widely known as deep learning, faced difficulties such as the natural occurrence of overfitting due to the vast number of parameters (synapses) on larger models. The most common model of this kind is the deep feedforward network, which propagate information in a single direction, and is similar to the MLP but with multiple hidden layers (d > 3). A similar model (deep belief network) gained attention in 2006 [22] when authors showed that the unsupervised training of layers as a way of weight initialization facilitates the use of deeper models. It is essential to notice that deeper networks also gained more attention due to the computer power of graphic processing units (GPU) [23]. In linear algebra, especially in vector and matrix operations, GPU is superior to CPU processing, allowing faster training of more significant amounts of neurons and layers. In 2012 the deep convolutional network AlexNet [24] was introduced, with clever training techniques and GPU implementation, demonstrating high discriminatory power on the ImageNet object recognition challenge [25]. Since then, deep models have become the predominant approach to computer vision, and several deep architectures have been proposed. However, almost all modern ANNs still contain some fully connected parts resembling the early MLP. Moreover, it has been shown recently that pure MLP models (with additional tricks) can be employed in deep learning tasks with state-of-the-art performance [26,27].

Parameters and training
This work focuses on fully connected, feedforward ANNs that resemble the MLP but with multiple hidden layers. Although this architecture is simple, there is a wide range of construction blocks, such as activation functions [28], synapse initializers [29], etc. For instance, for synapse initialization, which is the process of creating a random initial distribution to compose the weight matrices W a , there are optimized techniques such as Glorot-normal [29] rather than random uniform distributions. For neuron activation functions, most methods usually intend to project the inputs non-linearly. We can mention the Rectifier-Linear-Unit f (x) = x + = max(0, x) [28], an activation function that became popular after the widespread of deep models due to its simplicity and efficiency. However, these choices usually depend on the problem addressed or the architecture style, and they are defined mostly by empirical tests.
Moreover, beyond the ANNs construction stage, there are many training particularities, such as data preparation/normalization, optimizers, learning parameters, and stopping criteria. Current vision models usually normalize data according to the ImageNet standards [25], which consists of a z-score normalization that centers the data on 0 (subtracts the average) and makes the variance equals to 1. For training, popular optimizers are backpropagation [21] approaches such as the Stochastic Gradient Descent (SGD) with momentum [30]. Each optimizer has his hyperparameters that need to be tuned. The number of training epochs e is probably the most empirical one, where the user needs to supervise training performance to decide when to stop it.
In short, the ANNs development requires extensive architecture engineering and empirical tests that also is hardware demanding. This search is not random, i.e., there are good practices in the field and known configurations that work in a common scenario. However, they do not ensure the model will always work as expected. Moreover, other properties may also cause instability and vulnerability on neural networks, such as adversarial samples [4]. These drawbacks are another motivation for better understanding the internal dynamics of ANNs.

Complex Networks
The CN research field, or Network Science, emerged from the interaction between different areas such as graph theory, physics, and statistics. Its main goal is to study large networks derived from natural, complex processes. A classic example is the internet, a global network composed of many connected devices transmitting information worldwide. Furthermore, nature and modern society are filled with similar network-like systems, such as cell compound interaction, traffic flow, social networks, etc.
It is not simple to analyze complex systems due to the difficulty of deriving their collective behavior from a knowledge of the system's components [31]. Initially, researchers believed that most networks from natural complex systems had random topology [32]. However, researchers eventually found structural patterns, leading to better models to describe them. The most diffused ones are the scale-free [6], and small-world [33] networks. Therefore, these breakthroughs opened a new door for pattern recognition, where CNs are employed as a tool for the modeling and characterization of natural phenomena. These concepts are now applied in a broad range of areas [34].
A network can be defined by a tuple R = (V, E), where V = {v 1 , ..., v n } represents its vertices and E = {e(v i , v j )} the connections between vertex pairs. Each connection may be represented in several forms, and the most common approach is undirected, unweighted edges. That is, Weighted edges has a real value (not binary) associated with the connection between the vertices, i.e. e(v i , v j ) ∈ R, which may represent some kind of distance metric, connection strength or similarity. A network can also be represented by an adjacency matrix A = [a(v i , v j )] where i, j = 1, ..., n and a(v i , v j ) = 1 represents the existence of a link between v i and v j , and 0 represents no connection.

CN models and measures
From CN vertices and edges, it is possible to calculate a wide range of metrics to quantify its topology [35], each of which evidences a different aspect from the network. The degree is the most diffused measure, and can be calculated for each vertex v i by simply summing its adjacency matrix row ( j a(v i , v j )), representing the number of edges leaving v i . In weighted networks, this sum considers real values corresponding to each edge weight, and it is usually called weighted degree or strength The degree is the basis to describe several network properties, such as the scale-free phenomenon [6]. In these networks, the degree distribution follows a power law distribution p(s) ≈ s −γ , where γ varies according to the network structure. This topological pattern highlights hubs' existence, i.e., some vertices have a very high degree and play a critical role in the network's internal functioning. In contrast, most of the other vertices have a low degree. Several works have found the scale-free property in real-world networks from the most diverse domains, usually with γ ≈ 3.
It is also possible to calculate second order measures considering the properties of the node neighbors. This approach is based on the assortativity principle, i.e., that nodes tend to connect to other similar nodes. For instance, the average neighbor strength (for weighted networks) [36] of a node v i simply considers the mean strength of other nodes connected to it where N (v i ) define the set of nodes connected to v i . Another more complex measure following this principle is the second order centrality [37], which computes the standard deviation of the return times to a given node v i during a perpetual random walk on the network. In practice, it can be solved analytically, i.e., without the simulation of a random walk where a classical discrete time Markov chain M is employed (further details can be consulted on [37]). Another walk-based measure is the subgraph centrality [38], which considers all weighted closed walks, of all sizes, starting and ending at a given vertex. Each closed walk is associated with a connected subgraph, and the weights decrease with path length. This measure can be computed spectrally using the eigenvalues and eigenvectors of the adjacency matrix where u j is an eigenvector corresponding to the eigenvalue λ j of A.
In a similar fashion, it is possible to find graph cliques [39,40], i.e., a subset of nodes that are all adjacent. These objects can also be interpreted as a complete subgraph of the network. A maximum clique is the most extensive clique under this condition. It is possible to compute the number of maximum cliques that a vertex participates where Q is the set of maximum cliques in G, and M j are sets of nodes representing each maximum clique. Finding maximum cliques in a graph is a NP-complete problem. The search is usually performed by depth-first search algorithms and pruning the search tree, resorting to well chosen pivoting nodes [40].
Small-world networks [33] are models whose principal property is the facility for information spreading. In other words, these networks have a short average shortest-path distance where vertices can be reached easily (through few steps). Another essential property of these networks is their high clustering coefficient, which describes the level of interconnectivity between neighboring vertices. This measure counts the number of triangles (fully connected triple) that occurs between a vertex and its neighbors by is the number of triangles in which v i participates, or simply the number of edges between the neighbors of v i . It can also be computed for bipartite networks, also referred as bipartite local clustering [41] bc Path-based measures are also important for characterizing information flow, such as how fast a node communicates to the others. The harmonic centrality [42] considers this principle and computes the sum of the reciprocal of the shortest path distances from all the vertices to a given vertex where d(v j , v i ) is the Dijkstra's algorithm [43] for computing the shortest distance between two nodes v i and v j , considering the edge values for weighting the calculation. However, this computation ignores all other than the shortest paths. In some scenarios, information may flow throughout all the network paths. Therefore, some measures relaxes the shortest-path definition by including all paths and weighting according to its length. For instance, the current flow (CF) approach [44], inspired by the electric flow on circuits. The idea is to consider the network as a resistor network where edges are resistors and vertices junctions between resistors. The electric network analogy is achieved by computing the inverse Laplacian matrix (see [44] for further details). In this scenario, a possible measure is the CF closeness where corresponds to the effective resistance, i.e., the alternative distance metric between the two nodes which consider all possible paths on the eletric network.
Beyond the CN properties and measures we describe here, the literature is rich and heterogeneous on other approaches [35]. We limited our scope here due to several factors we discuss further in the following section.

Methodology
In this work, we analyze the internal CN properties of fully connected neural networks and their correlation to classification performance on vision tasks. This architecture is considered one of the most diffused models since early neural networks studies, and it is still popular among modern deep methods. Its number of parameters (synapses) grows exponentially with the number of neurons and layers. To uncover topological properties emerging in such systems, this  ample parameter space needs to be explored in more depth. However, it becomes impractical to compute every possible combination to even small architectures. Therefore, we propose constructing a neural network population with different properties within the most common practical scenarios in the field. This approach allows the comparison between a wide range of neural networks, which is one of the main differences to previous works such as [14,15].

Dataset construction: training a neural network population
We propose a new neural network dataset composed of a wide range of synapse configurations. The idea is to use a fixed architecture (number of neurons and synapses) and training hyperparameters, then train networks of different initial weights. For that, we vary the seed of the random number generator that produces the synapse distributions (for specific details, check our repository 1 ). In this sense, it is possible to widely explore the synapse space of random initial networks and analyze how it impacts the training dynamics and final behavior. After training, even networks of similar performance have different initial weight configuration, allowing us to analyze recurrent CN properties emerging between them. It is important to notice that the idea for building our dataset is different from previous works on Neural Architecture Search (NAS) [45]. In these works, the goal is to search and optimize architectures for better performance, while here we are storing the entire network for tacking the properties which explain their performance.
Firstly we define the architecture for our study. This choice depends on the problem one needs to address; we focused on supervised classification on vision tasks. An MLP-like architecture is considered, where the input patterns are grayscale images of sizes 28x28, which are fed into a flattened layer of 784 neurons. Two hidden layers, with 200 and 100 neurons (n = 300), respectively, employ the ReLU activation function. The output layer comprises ten neurons with a softmax activation function, representing a 10-class classification task (benchmarks are described later). Here we do not consider bias terms for simplicity. This architecture yields 177,800 trainable parameters. Figure 1 (a) shows a summary of the model, which we implemented using the Keras 2.2.4 library 2 . In Figure 1 (b), we show all the model's neurons and synapses using a network visualization technique that clusters vertices according to their degree. Neuron colors represent its corresponding layer, while edge colors refer to the synapse signal (green for positive and red for negative).
To achieve different networks from this same architecture, we vary the weight initialization. Novel techniques, such as the Glorot initializer [29], optimize the weight distribution by fitting a normal curve around 0 with a small standard deviation. In practice, this tends to produce similar, more stable networks and may help with training. However, our focus here is not on better performance but on heterogeneity. Therefore, we use an initialization technique that allows a broader range of possible weight configurations. We consider a uniform distribution in the interval [−0.9, 0.9]. Using a wider range such as [−1, 1] tends to produce poorer models, while compressing it tends to produce more similar models. The considered interval generates more diverse networks at both ends regarding performance in different vision benchmarks. For the training, we considered the following: SGD optimizer on a categorical cross-entropy loss function, learning rate α = 0.01, and batch size 100. We observed that the training usually stabilized around 15 to 20 epochs, then a total of 30 training epochs were considered. With the described architecture and training procedure, we address the following four vision benchmarks: • MNIST [46]: This is one of the most known computer vision benchmarks, with grayscale 28x28 images representing handwritten digits from 0 to 9; some samples are shown on Figure 2 (a). It comprises 60 thousand images for training and 10 thousand for the test where the goal is a 10-class classification problem to identify each digit. It is important to note that all the other four benchmarks described here have the same number of classes.
• Fashion MNIST [47]: This dataset consists of a more complex visual structure, with detailed objects rather than almost-binary pixels in comparison to MNIST. Fashion MNIST is composed of grayscale clothing images, with the following classes: t-shirt, trouser, pullover, dress, coat, sandals, shirt, sneaker, bag, and ankle boots. Samples of each class are shown on Figure 2 (b).
• CIFAR-10 [48]: To include a different visual problem, we considered this object classification dataset. The CIFAR-10 variant comprises grayscale samples of 10 classes: airplane, automobile, bird, cat, deer, dog, frog, horse, ship, and truck. It is a more challenging classification problem as images are uncontrolled and objects conditions and positions vary greatly (some samples are shown in Figure 2 (c)).
• KTH-TIPS [49,50]: Texture classification is another important problem in computer vision. Therefore we considered this well-known benchmark. The original KTH-TIPS 2 dataset comprises RGB images of 10 texture classes: aluminum foil, cork, wool, corduroy, linen, cotton, brown bread, white bread, wood, and cracker. We built a different dataset by cropping the original 200x200 samples (different sizes are not considered) into 28x28 non-overlapping grayscale images. We divide the new crops into training and testing folds by ensuring that no crops of the same image appear together in the same fold. It yields a total of 165 thousand samples for training and 35 thousand for the test. We then randomly choose 60 thousand images for training and 10 thousand for the test. Our version of KTH-TIPS is available at 3 , samples of each class are shown on Figure 2 (d).
For each dataset, we train a population of 1000 neural networks, each one with a different random seed for weight initialization. The remaining configuration, such as training algorithms and batch order, are kept fixed for all networks. The result is a fairly distributed population of 4000 models in terms of final test accuracy, as Figure 3 shows.

Neuronal Complex Network characterization
Considering the neural network population, we compute CN centrality measures from its neurons. Each network can be directed modeled as weighted, undirected, and bipartite graphs. Given the new graph representation G, centrality measures can be computed to describe each neuron n i (f (n i )). This is a classic approach in CN research, where methods try to estimate the vertex centrality, or importance, for the model structure and dynamics. Vertex centrality is, therefore, an important property of CNs and have helped to identify critical properties in a wide range of real-world systems [34]. Considering that the literature is rich on such methods [35], it is possible then to characterize neurons in different perspectives, as different measures has a different topological meaning. For that, we compute centrality from hidden neurons (layers [L 1 , ..., L d−1 ]), i.e., as our samples are 4-layers deep, only neurons from layers L 1 and L 2 are considered. The input and output layers are not considered as they are structurally different (connections in just one direction), and the first and last hidden layers already include their connections. Considering a hidden neuron n i in the graph representation, it is possible to calculate a given measure f (n i ) to characterize it. We narrowed down a set of specific measures considering different approaches/paradigms and some practical characteristics such as complexity/computation time and availability in known libraries (for easy reproduction). This was carried out considering the possibility of future practical applications of our findings, considering that some CN methods are too expensive to be employed in modern deep neural networks. It is also important to notice that some measures cannot provide useful information for regular/fully connected graphs. Therefore we employ some threshold techniques (described below).
The NetworkX 2.4 library 4 is employed for computing network properties, which is one of the most complete and diffused frameworks in python [51]. An analysis on the computational complexity and specific parameter details of each CN measure is beyond the scope of this work. The reader may refer to their original papers and also the NetworkX documentation, which considers the best practices in terms of implementation and analysis of these methods. NetworkX and python are used also considering another important properties such as open source code and the ease to combine it with the most common neural network libraries (Tensorflow and Keras), allowing us to release our implementation in a single programming language 1 . Finally, we describe the CN measures in the following: • Weighted degree, or strength (s) Equation 3: Represents the neuron strength, the rate at which it lets information flow. High positive strength means an excitatory neuron that gives higher importance to both its incoming and outgoing connections. Near zero means average neuron, a neutral neuron (connections near zero), or a neuron with half positive and half negative connections, configuring an antagonistic neuron. Negative strength is the predominance of negative connections, which means inhibitory neurons. This measure is computed over the original neural network, with all its edges and weights. : This is a path-based approach, inspired by the electric flow on circuits. Each neuron pair is considered a source-target pair, where current is injected at the source and drained at the target. The measure then quantifies the importance of neurons for the electric flow throughout all the neural network paths, i.e., the synapse flow. This approach is more realistic in a neural network than the other centrality measures which assume that information flows exclusively through the shortest paths. This measure is computed over the original neural network, with all its edges and weights.
Considering these centrality measures, we propose local neuron descriptors, or global average features from each hidden layer. Given a hidden layer L i with n neurons, and a given measure f , a feature vector can be obtained The vector υ f preserves neuron order on the layer. However, this order is not meaningful as the network is fully connected, and it also depends on the random initialization. To remove this spatial information we compute the layer average For local characterization, it is possible to compute a set of descriptors to a given neuron by combining different measures. A local feature vector is then expressed as where n i ∈ V is a vertex representing a neuron from hidden layers, and f j is a CN measure (f j ∈ [s, s w nn , CF c , bc, sg, hc, so, mc]). In this sense, each neuron is a sample to be characterized and not the whole layer or neural network. By analyzing the local descriptors ψ(v i ) from all neurons, it is then possible to characterize the local topological properties of the neural network.
We employ a non-supervised approach to find neuronal signatures by grouping local descriptors with similar features. This approach has been employed for image recognition and is usually called bag-of-visual-words [52]. It derives from the bag-of-words method, which considers the word frequency (features) from a given vocabulary of k types. In the case of visual words, features are real-valued vectors representing local image properties. Here, our features are neuronal topological signatures expressed through the CN measures of each neuron. Given a set of neural network graphs P = [G a ], a matrix is built by stacking neuron descriptors from all neural networks in P where D has dimensions |P |n a -by-m, where |P | is the number of graphs in P , n a the number of hidden neurons in each neural network and m the number of measures. We consider P as the set of neural networks trained for a given vision benchmark, n a = n = 300 (see the architecture description), and m is the number of considered CN measures (further discussed on Section 4).
D represents all the CN neuronal properties from a set of networks P , which is considered to build the vocabulary of the k most relevant features, or neuron groups. We call this method bag-of-neurons (BoN), where each vocabulary element represents a neuron type that usually occurs in these neural networks. To find them, the k-means clustering (or Lloyd's algorithm) is applied to obtain group centers in a non-supervised fashion. It finds k centroids (group centers) by first starting with random positions and then iteratively averaging its distance to nearest sample points (D rows). In other words, it minimizes the within-cluster sum-of-squares (inertia) and tends to converge to regions where samples cluster together. This algorithm is usually employed due to its simplicity and performance, and it is commonly cited among the best data mining methods [53]. The k + + method [54] is considered for initialization (rather than regular random sampling), which spreads the initial clusters with probability proportional to its squared distance from the point's closest existing cluster center. We also consider relative tolerance 10 −3 with regards to the Frobenius norm of the difference in the cluster centers of two consecutive iterations to declare convergence. The matrix D is feature-wise normalized by the largest value to avoid disproportion in the Euclidean distance calculation. A total of 100 repetitions is performed each time we run the k-means algorithm, and the best result based on inertia is used. This result is a set of m-dimensional centroids C = [ψ 1 , ..., ψ k ] representing the features of the k most common neuron types. It is important to notice that even when using k + + and performing 100 repetitions, the position of the centroids may still slightly vary by some decimal places, as the process is still random.

Analysis and Results
We first analyze the apparent correlation between CN measures and the neural network performance by computing vectors υ Li,f for each hidden layer, given a measure f (see Equation 11). It summarises all the neural information into two values (1 for each hidden layer) for each measure. For a qualitative analysis, the information is visualized in two axis where x = υ L1,f and y = υ L2,f , representing the 2D spatial distribution of each neural network. Results are shown in Figure 4 and contain the best, and worst 100 samples in terms of test accuracy on the Fashion MNIST dataset, and color represents the test accuracy. It is possible to notice that some measures projections are practically linearly separable considering the two performance groups of networks, more specifically the strength (s), bipartite local clustering (bc), second-order centrality (so), and the number of cliques (mc). The subgraph centrality (sg) shows a total correlation between the first and second hidden layer, with a small difference in scale probably related to the different number of neurons and synapses it contains. Nonetheless, it is still possible to distinguish the two groups of networks even if considering the information from a single axis.
On the other hand, results suggest that the average nearest-neighbor strength (s w nn ), current-flow closeness (cf c), and harmonic centrality (hc) are not able to express the correlation between neural network topology and performance. It is not easy to directly determine why they fail to tackle the correlation, as they represent different aspects from the graph. For instance, in [14] authors have shown that the average nearest-neighbor degree may be correlated to the functioning of some receptive fields, but they do not discuss it in depth. However, it is not intuitive to believe that the assortativity principle take place on fully connected feedforward neural networks in terms of CN properties. For instance, considering neurons from the first hidden layer its neighbors are, respectively, the input and second  hidden-layer, which most probably have a different role in the network dynamics. The same accounts for the neighbors of neurons from the second hidden layer, i.e., the output and first hidden layers. Therefore, considering the 4-layer architecture we analyze, our results suggests the absence of correlation between assortativity and performance. On the other hand, this assumption may not hold for deeper networks and broader vision tasks, as larger models may contain more redundancy.
Results also suggests that the CF closeness (cf c) and harmonic centrality (hc) are not directly related to neural network performance. Considering that both are path-based measures, we conclude that this kind of information may not correlate directly to the model accuracy. Therefore, as our goal on this work is to understand structure and performance, they are not considered for the next analyses (along with s w nn ). Nonetheless, they are present on the dataset we make available 1 and further studies on different scenarios would be interesting.
Different centrality measures may have considerable correlation even in networks from diverse domains [55]. For instance, random walks may be attracted to higher degree nodes, reflecting the degree distribution. Therefore, we consider the Pearson's correlation between measure pairs to discard redundant information. The local descriptor ψ(v i ) of each neuron (see Equation 12) is computed considering each measure individually, resulting in a single value. We then cross these values for each measure pair, for each hidden layer separately. Each plot on Figure 5 shows the measure pairs for all neurons from the 1000 neural networks (trained on Fashion MNIST), along with the corresponding Pearson's correlation ρ. If a pair of measures have |ρ| > 0.8, we remove one of them to reduce redundancy and keep the simplest measure (lowest computer cost). The strength has a high correlation with the second-order centrality and maximum cliques; thus, we keep the former and remove the other two. The removed measures (so and mc) also present a considerable correlation between themselves, corroborating that they provide low contribution for characterizing the neural network performance.

Bag-of-Neurons properties
The remaining 3 measures are considered for neural network characterization by building the local neuron descriptor ψ(v i ) = [s(v i ), bc(v i ), sg(v i )] and combine them to obtain matrix D (see Equation 13). Our BoN approach is then performed to obtain neuron groups in a non-supervised fashion using k-means. One of the drawbacks of k-means is that the parameter k must be given beforehand, i.e., the number of data groups must be known, which is one of the main problems in data clustering regardless of the chosen algorithm. In our case, we cannot assume the number of possible neuron types in neural networks according to CN principles, nor did any previous work. Therefore, we use the elbow method for estimating the optimal number of groups which is a heuristic based on the distortion measure obtained from various k values. This measure sums squared distances from each sample point to the nearest centroid found by k-means. Normally, increasing the number of clusters will naturally reduce the distortion since there are more clusters to use, but at some point, it is overfitting. The elbow method then estimates the point of inflection on the curve so that adding another cluster doesn't give much better modeling of the data. We tested k values from 2 to 18, results are shown in Figure 6. It is possible to observe that the elbow method indicates optimal k around 6 in any case, either when grouping neurons from the first or second hidden layer separately or combined. It also happens independently of the dataset on which the neural networks were trained. This indicates an universal behavior of six topological signatures emerging on neurons within these networks, in different scenarios.
Considering the k-means results using k = 6 over matrix D with all hidden neurons, the obtained centroids ψ i on each dataset are shown on Table 1, sorted by strength (s). Another interesting pattern is observed here. The six neuron types detected are very similar across tasks, mainly when looking at strength and bipartite clustering. There are some particularities where measures vary from other cases, for instance, the strength and subgraph centrality on CIFAR10 at     neuron type ψ 6 , but most of the remaining properties are similar. Differences are expected in some cases, mainly on the first hidden layer, due to the natural differences in the input image patterns. For instance, MNIST represents digits covering a fraction of the image, while the remaining pixels are background. Fashion MNIST has a similar structure, with multiple background pixels. On the other hand, CIFAR10 and KTHTIPS has grayscale pixels covering the whole image (in most cases). The amount of background pixels then causes neurons of the first hidden layer to become more or less inhibitory. It directly influences the number of synapses connected to background information. Nevertheless, this seems to have a small impact on the six neuron types we found, while most of them have similar topological properties across the different tasks. This behavior also points to global topological patterns emerging from neural networks with different initial synapses and trained on different domains.
Using the obtained BoN is then possible to find neurons that match one of the six groups by simple nearest-neighbor association to its local descriptor. To better compare the average structure of networks with different performance, we consider models from 3 accuracy ranges and compare their differences of neuron type occurrence. Figure 7 shows the distribution of neuron types for each benchmark the neural networks were trained. They are grouped according to the colors: red represents the 100 networks with lower accuracy, blue is the 100 around the median, and green the top 100. We can see some similarities across different tasks again. For instance, the occurrence of most neuron types follows a similar shape. These findings aligns with the results of [14], where authors have shown that receptive fields (neurons) with similar function develop similar topological properties in different target domains (they considered two benchmarks). It is widely known that receptive fields in deep neural networks tends to progressively extract higher-level features from the input. In vision, our study-domain, the first layers would then detect simple visual cues such as lines and circles, while deeper layers combine it into more detailed features. The simple features are usually universal, independently from the target domain.
The most interesting property we can observe within the neuron types occurrence is how the distributions change according to the neural network performance. The occurrence of most neuron types is clearly different for each accuracy range (colors). Another important finding is that neuron type ψ 3 is the most common among the best neural networks, having the highest occurrence and also highest occurrence difference to the lower performance networks. This group of neurons has a slight negative strength, closer to 0 compared to other neuron types. This phenomenon explains why weight initializers with normal distribution in small ranges around zero (such as Glorot [29]) tend to yield better results than widely uniform initializers. Combining with the other properties of this neuron type, we can assume that there is a strong tendency for neural networks with higher accuracy to contain around 30% of hidden neurons with a slight negative strength −0.1 ≤ s ≤ −0.05, a considerably high clustering coefficient bc ≈ 0.8, and subgraph-centrality 0.08 ≤ sg ≤ 0.16. On the other hand, neuron type ψ 4 seems to be less critical for better-performing networks, and it appears more frequently among those with worse performance. These neurons have a small strength magnitude and one of the highest clustering coefficients. However, their most interesting property is the highest subgraph centrality than all other types, by a significant margin, and this is also observed throughout different benchmarks. It is a notable contrast and highlights the difference between structure and performance on these networks. We then conclude that neural networks with poor performance tend to have considerably more neurons with higher subgraph centrality (sg > 0.3) when compared to other networks. This property may be highlighting neuron saturation, usually caused by fading/exploding gradients during gradient descent, which would explain why these networks fail to achieve higher performance.     We also calculate the similarities in neuron type occurrence when obtaining the BoN in different benchmarks. The Jensen-Shannon Divergence (JSD) is considered, which provides a smoothed and normalized version of the Kullback-Leibler Divergence [56] (KLD). This metric quantifies the difference (or similarity) between two probability distributions, with scores between 0 (identical) and 1 (maximally different). We compute neuron types occurrence on networks for BoNs obtained in the same benchmark the model was trained (ψ), or in a different benchmark (ψ). We then calculate KLD(ψ,ψ) = i p(ψ i ) log( p(ψi) p(ψi) ), which is used for computing JSD = 1 2 (KLD(ψ, ψ+ψ 2 ) + KLD(ψ, ψ+ψ 2 )). The JSD is then averaged over frequency pairs of all 1000 networks, for all possible combinations between benchmarks for construction and application of the BoN, results are shown on Table 2. Despite the high standard deviation, the average divergence values are relatively low, around 0.21 and 0.33, which indicates significant similarity between neuron types. Nevertheless, these results suggest an average behavior of similarity emerging within neuron types from BoNs obtained with neural networks trained on different benchmarks.

Conclusion
In this work, we explore the correlations between the structure and performance of fully connected neural networks on large vision tasks. Our first contribution is a new dataset with 4 thousand neural networks, each with different initial random synapses, applied on known vision benchmarks (MNIST, Fashion MNIST, CIFAR10, and KTH-TIPS). We then consider each neural network as weighted and undirected graphs and focus on analyzing local neuron properties. Eight CN centrality measures are computed for each hidden neuron, which is also included in the dataset. Our analysis shows that some of them (average nearest neighbor strength, current-flow closeness, and harmonic centrality) do not present relevant information regarding the model's performance. We also find redundancy in some cases, where correlations were high (second-order centrality and number of cliques). In the end, three centrality measures contain the most relevant information (strength, bipartite clustering, and subgraph centrality) and show interesting neural network properties.
Our results show a strong correlation between neuronal centrality properties and neural network performance. In some cases, it is possible to linearly separate the top and worst 100 neural networks by simply taking the hidden layers average of a single CN measure. We also propose a local descriptor for hidden neurons by concatenating the three best measures and found that they are usually grouped in 6 neuron types throughout the neural network population. Each group has a distinct topological signature and share similarities even between the different tasks the neural networks are employed. Some neuron types are more common than others, and their distribution seem to be directly related to performance. We were able to highlight the CN properties related to this phenomenon, with distinct differences between different performing networks. For instance, neurons wit a combination of high clustering coefficient, and, most importantly, a distinct higher subgraph centrality tends to emerge more frequently on lower performing models.
Network science is a strong candidate to understand the internal properties of neural networks. Our results shows that the structure and performance of fully connected models seem to be directly related. Our findings are important for understanding the functioning of neurons, their learning dynamics, and their impacts on the whole system performance. We will consider these CN properties dynamically for future works, i.e., how they emerge from random initial weights during training and the impacts of different initial structures. Moreover, to analyze the system stability, such as the impacts of adversarial samples. And finally, to target practical applications of these principles, such as employing CN properties for better neural network construction, stability, and learning.