# EDC-Net: Edge Detection Capsule Network for 3D Point Clouds
## 3 Proposed Method
### Network Architecture
#### 3.1.5 Routing Mechanism  
A routing mechanism in capsule networks is an operation for updating the weights between capsules. Therefore, the properties captured by capsules can be propagated to suitable capsules, where different capsules reflect the properties of point cloud from different aspects. The task of a routing mechanism is to define the global coherence of the features and it performs by learning part-whole relationships. We concatenate the output of the primary capsules after applying the attention module with the output of the convolutional features. The convolutional layer features are local features and the features from primary capsules after the attention module are global features. This concatenation process is required to achieve point-wise segmentation results through the routing mechanism. The shape of the output of the first convolution after max-pooling is \(N\times 64\). The shape of the output of the primary capsules after max-pooling is \(N\times 16\times 4\); also it maintains the same shape after applying the attention module. Accordingly, we reshape the convolution of shape \(N\times 64\) to \(N\times 16\times 4\) in order to concatenate it with the  
Figure 2: The structure of the attention module. \(\otimes\) stands for multiplication. features from the attention module of primary capsules. Therefore, the features for routing mechanism have a shape of \(N\times 16\times 8\), and are defined by \(f=\{f_{1},...,f_{i},...,f_{n}\}\) where \(n\) is equal to 8; and 8 is the number of these latent capsules in the routing mechanism--there are 4 capsules for the local features and 4 capsules for the global features. Furthermore, \(f_{i}\) is the feature in each one of the latent capsules of dimensions \(N\times 16\). The routing mechanism determines the connection between input and output capsules of the process. In EDC-Net, we define the dimensions of the EdgeCaps module by 2 since we have two classes of edge and non-edge points. In the routing mechanism, there are coupling coefficients denoted by \(C\) between the latent capsules and EdgeCaps capsules, where \(C=\{C_{11},...,C_{ij},...,C_{nm}\}\), where \(1\leq i\leq n\leq 8,j\leq m\leq 2\); the summation of all of the coupling coefficients is equal to one. The coefficient values are computed by a routing softmax which is initially defined by \(b_{ij}\). The \(b_{ij}\) represents the logit of \(i\)-th index of the latent capsules and \(j\)-th index of the EdgeCaps capsules. The \(b_{ij}\) is initialized with zero at the first iteration of the dynamic routing mechanism. Then, it is rectified iteratively by evaluating the agreement between the capsules. Hence, coupling coefficient values are computed as \(C_{ij}=\frac{exp(b_{ij})}{\sum_{i=1}^{n}exp(b_{ij})}\), where \(z\) represents the iterator through all capsules. The coupling coefficients are the log prior probabilities and they are updated by the iterative routing process. Afterwards, by multiplication of all the features \(f\) with the routing coefficient \(C\), we obtain the list of prediction vectors \(\overrightarrow{P}=\{\overrightarrow{P}_{11},...,\overrightarrow{P}_{ij},..., \overrightarrow{P}_{nm}\}\) for each vector of capsule \(\overrightarrow{P}_{ij}=C_{ij}f_{i}\). Each capsule consists of a weighted sum \((S_{i})\) of all prediction vectors in order to make a connection between capsules \(S_{j}=\sum_{i=1}^{n}\overrightarrow{P}_{ij}\). The list of prediction vectors \(\overrightarrow{P}\) represents the probability of similarities of features with respect to the features of each point. Hence, in order to define more similar prediction vectors close to _one_ and less similar prediction vectors close to _zero_, we apply a non-linear squashing function [23], \(V_{j}=\frac{||S_{j}||^{2}}{1+||S_{j}||^{2}}\frac{S_{j}}{||S_{j}||}\), where \(V_{j}\) is the vector output of capsule \(j\) and \(S_{j}\) is its total input.