## 3 Method
### Learning Algorithm  
Various substantial implementation settings have been studied to design the learning algorithm, including non-linear model topologies, shared input, and multiple model inputs and outputs. Typically, a deep learning model is a compound directed acyclic graph (DAG) structure of different layers. An extension to DAG is to build graphs of layers. In our training routine (Algorithm 1), the proposed deep learning structure runs multiple instances non-linearly and shares the input. We reused the unit architecture and its weights by running the multiple instances of the proposed PrimeNet structure.  
```
1:Input: Batch Images
2:Output: Prediction
3:procedureTRAIN()
4:\(capsuleX\)=\(Capsule()\)\(\triangleright\) Shallow network instance for x scale.
5:\(capsuleY\)=\(Capsule()\)\(\triangleright\) Shallow network instance for y scale.
6:\(capsuleZ\)=\(Capsule()\)\(\triangleright\) Shallow network instance for z scale.
7:\(classifier\)=\(PrimeNet()\)\(\triangleright\) Classifier Network Instance.
8:procedurefeature_train(images)\(\triangleright\) Individual capsule training for feature generarion
9:\(featuresX\) = \(capsule(images)\)\(\triangleright\) Features X from Capsule X.
10:\(lossX\) = \(loss(featuresX)\)\(\triangleright\) loss from feature X.
11:\(featuresY\) = \(capsule(images)\)\(\triangleright\) Features Y from Capsule Y.
12:\(lossY\) = \(loss(featuresY)\)\(\triangleright\) loss from feature Y.
13:\(featuresZ\) = \(capsule(images)\)\(\triangleright\) Features Z from Capsule Z.
14:\(lossZ\) = \(loss(featuresZ)\)\(\triangleright\) loss from feature Z.
15:if(\(lossX<lossY\)) &(\(lossX<lossZ\)) then
16:\(min\_loss\_features\)=\(featureX\)
17:elseif(\(lossY>lossX\))&(\(lossY>lossZ\)) then
18:\(min\_loss\_features\)=\(featureY\)
19:else
20:\(min\_loss\_features\)=\(featureZ\)
21:endif
22:\(gradient\_update(capsuleX,capsuleY,capsuleZ)\)\(\triangleright\) local gradient update
23:endprocedure
24:for epoch in range(epochs) do
25:\(classifier\_loss=0\)
26:\(total\_classifier\_loss=0\)
27:for batch_images in train_dataset do
28:\(MinLossFeature\)=\(feature\_train(batch\_images)\)
29:\(features\)=\(MinLossFeature+input\_projection\)\(\triangleright\) Input feature projection is concatenated.
30:\(classifier\_output=classifier(features)\)
31:\(classifier\_loss=loss(classifier\_output)\)
32:\(total\_classifier\_loss+=classifier\_loss\)\(\triangleright\) Combined classifier loss
33:\(update\_weights\)=\(gradient\_update(classifier)\)
34:endfor
35:endprocedure
```  
**Algorithm 1** Training algorithm for classifier model.  
Further, to learn from the local multiscale representations (Capsule instances) and transfer the encoding for final classification (classifier model), our iterative training strategy chains the dynamically selected capsule output with the classification model. In the first part, we trained the batch input through the proposed selection network block (Figure 3) and obtained the local representation for local loss computation. After computation of the local loss, we compared the capsule for minimum loss and transferred the capsule instance's convoluted output to the classifier block. In the classifier part of the training, the selected convolved output from the capsule is concatenated with input feature projection. The input feature projection presents a local translation-invariant version of the input, which further balances the domination of correlated regions in overall feature representation. The rest of the classifier block is designed as a simple convolutional network that facilitates a swift classification of dynamically learned feature representations.