Hierarchical Training of Deep Neural Networks Using Early Exiting
Deep neural networks provide state-of-the-art accuracy for vision tasks but
they require significant resources for training. Thus, they are trained on
cloud servers far from the edge devices that acquire the data. This issue
increases communication cost, runtime and privacy concerns. In this study, a
novel hierarchical training method for deep neural networks is proposed that
uses early exits in a divided architecture between edge and cloud workers to
reduce the communication cost, training runtime and privacy concerns. The
method proposes a brand-new use case for early exits to separate the backward
pass of neural networks between the edge and the cloud during the training
phase. We address the issues of most available methods that due to the
sequential nature of the training phase, cannot train the levels of hierarchy
simultaneously or they do it with the cost of compromising privacy. In
contrast, our method can use both edge and cloud workers simultaneously, does
not share the raw input data with the cloud and does not require communication
during the backward pass. Several simulations and on-device experiments for
different neural network architectures demonstrate the effectiveness of this
method. It is shown that the proposed method reduces the training runtime for
VGG-16 and ResNet-18 architectures by 29% and 61% in CIFAR-10 classification
and by 25% and 81% in Tiny ImageNet classification when the communication with
the cloud is done over a low bit rate channel. This gain in the runtime is
achieved whilst the accuracy drop is negligible. This method is advantageous
for online learning of high-accuracy deep neural networks on sensor-holding
low-resource devices such as mobile phones or robots as a part of an edge-cloud
system, making them more flexible in facing new tasks and classes of data.
Yamin Sepehri, Pedram Pad, Ahmet Caner Yüzügüler, Pascal Frossard, L. Andrea Dunbar
# Hierarchical Training of Deep Neural Networks Using Early Exiting

###### Abstract

Deep neural networks provide state-of-the-art accuracy for vision tasks but they require significant resources for training. Thus, they are trained on cloud servers far from the edge devices that acquire the data. This issue increases communication cost, runtime and privacy concerns. In this study, a novel hierarchical training method for deep neural networks is proposed that uses early exits in a divided architecture between edge and cloud workers to reduce the communication cost, training runtime and privacy concerns. The method proposes a brand-new use case for early exits to separate the backward pass of neural networks between the edge and the cloud during the training phase. We address the issues of most available methods that due to the sequential nature of the training phase, cannot train the levels of hierarchy simultaneously or they do it with the cost of compromising privacy. In contrast, our method can use both edge and cloud workers simultaneously, does not share the raw input data with the cloud and does not require communication during the backward pass. Several simulations and on-device experiments for different neural network architectures demonstrate the effectiveness of this method. It is shown that the proposed method reduces the training runtime by \(29\%\) and \(61\%\) in CIFAR-10 classification experiment for VGG-16 and ResNet-18 when the communication with the cloud is done at a low bit rate channel. This gain in the runtime is achieved whilst the accuracy drop is negligible. This method is advantageous for online learning of high-accuracy deep neural networks on low-resource devices such as mobile phones or robots as a part of an edge-cloud system, making them more flexible in facing new tasks and classes of data.

 Hierarchical Training, Early Exiting, Neural Network, Deep Learning, Edge-Cloud Systems

## I Introduction

Deep Neural Networks (DNNs) have shown their effectiveness in different computer vision tasks such as classification [1][2], object detection [3][4], and body-pose estimation [6]. These methods outperform the previous classical approaches in all of these areas in terms of accuracy. However, in general, these state-of-the-art DNNs are made of complex structures with numerous layers that are resource-demanding. For example, ResNet-18 is made of 72 layers structured as 18 deep layers and around 11 million trainable parameters [5]. Implementation of DNNs requires high computational resources to perform many multiplications and accumulations and a high amount of memory to store the vast number of parameters and feature maps. This issue is far more critical in the training phase of DNNs as it is more intense in terms of computations than the inference phase [7] due to the higher number of FLOPs in the backward pass in comparison to the forward pass and the additional operations needed to update the parameters [8]. All these demanding operations are often done in multiple passes in the training phase. Moreover, as the parameters, their updates and the layers' activation maps should be stored, the memory requirement is also higher in the training phase [9].

The large resource requirements for training classical DNNs make their implementation often unsuitable for resource-limited edge devices used in IoT systems. The conventional solution to this issue is to offload DNN training to cloud servers, which are abundant in terms of computational resources and memory. However, training DNNs on the cloud requires sending the collected input data from the edge to the cloud. This data communication increases the total latency of training. This training latency is crucial when one needs fast online learning and seamless adaptation of models in tasks like human-robot interaction [11]. Additionally, in many tasks, the dataset contains sensitive content such as personal information like identity, gender, etc., which raises privacy concerns if they are sent to the cloud due to the possibility of untrusted connections or cloud service providers [10].

To overcome the above problems, different hierarchical training methods have been proposed. The goal of hierarchical training is to train a complex DNN more efficiently by bringing it closer to where the data is acquired by sensors, i.e. the edge worker. As the edge cannot handle the whole training task of the DNN, a part of the training phase is outsourced to another device with substantial resources, i.e., the cloud worker. In other words, it offers a method to efficiently train the DNNs on a heterogeneous hierarchy of workers. Other optional levels may also be added in between, that represent local server workers which are closer to the edge but with lower resources in comparison to the cloud. For example, in [12], the authors analyzed the different workers as different graph nodes and found the shortest path to decide the schedule of execution on different workers, and in [13], the authors divided the data batches between the different workers with respect to their resources. Although these methods successfully divided the training phase between the workers, they suffered from issues such as high communication cost due to the several data transfers between the workers [12], and privacy concerns as they send directly the raw input data over the network [13].
In this work, we propose a novel hierarchical training framework using the idea of early exiting that provides efficient training of DNNs on edge-cloud systems. The proposed method addresses the issues of training on edge-cloud systems and mitigates the communication cost, reduces the latency, and improves privacy. Our method reduces the latency of training and privacy concerns as it does not send the raw data to the cloud; instead, it shares a set of features only. In order to achieve this goal, we benefit from the idea of early exiting at the edge, which was solely used in full-cloud training to achieve higher accuracy in specific architectures like GoogLeNet [14], or the inference phase of hierarchical systems [15]. We use early exiting to split the backward pass of training in the DNN architecture parts implemented at the edge and the cloud. It provides the possibility to partially parallelize the training over the edge and the cloud workers, enabling the use of their full potential and reducing the latency. Our early exiting approach does not need to communicate the gradients between the workers in the backward pass. Moreover, it enables the use of non-differentiable operations such as quantization to compress the communicated data in the forward pass. It also has the side benefits of providing robustness against network failures and a possibility of reduction in the edge power consumption, since there is no need to communicate the backward pass gradients from the cloud back to the edge.

We perform extensive experiments and compare the performance of our novel model with the baseline of full-cloud training, that is the scenario of communicating the input data directly to the cloud and training the neural network there. We show in on-device experiments that our method can reduce the latency of training in comparison to the baseline while having a negligible amount of accuracy reduction. It improves the training runtime significantly, especially when the communication bandwidth is low. The advantage of our method in terms of computational and memory requirements and communication burden is also shown in our experiments.

Our proposed method is especially useful in online training on resource-constrained devices that acquire their own data from their built-in cameras, like mobile phones or robots. It allows training high-accuracy DNNs for the given tasks without the need for having high computational and memory resources, nor to share their private raw data with cloud severs.

The main contributions of this work are summarized as:

* We propose a novel approach to train DNNs in hierarchical edge-cloud systems, using early exiting. It results in lower latency, reduced communication cost, improved privacy, and robustness against network failures with respect to a classical full-cloud training framework.
* We propose guidelines to efficiently select the partitioning strategy of the DNN between the edge and the cloud based on specific requirements such as runtime, accuracy or memory.
* We conduct a performance analysis and show the advantage of the proposed hierarchical training method in terms of memory consumption, computational resource requirement and communication burden. We perform extensive simulations and calculate the latency of different architectures of DNNs when they are trained with our edge-cloud framework and show their superiority over the full-cloud training while having a negligible accuracy drop.
* We implement the system and perform on-device experiments to show the runtime improvements in an experimental edge-cloud setup to validate the proposed idea.

The manuscript is structured as follows: the related works are described in Section II. After that, the proposed hierarchical training approach is elaborated in Section III. Section IV is dedicated to the experiments and their results and the study is concluded in Section V.

## II Related Works

In this section, we describe the related works and divide them into three groups: hierarchical training, early exiting, and hierarchical inference.

### _Hierarchical Training_

The idea of training a DNN on a system of hierarchical workers with different available resources has recently received attention from researchers. In these works, the authors try to train a DNN directly on an edge-cloud system. Eshratifar et al. [12] proposed the idea of JointDNN that defines the blocks of a DNN that are executed on each worker as graph nodes and proposed a method of DNN division by solving the shortest path problem in this graph. Although their method is able to improve the runtime and energy consumption of the training phase, it cannot benefit all levels of the hierarchy at the same time due to the sequential nature of the training phase. Additionally, the communication cost is still high between the mobile and the cloud levels as their proposed method sometimes has more than the two usual communication stages (for the forward pass and the backward pass).

Liu et al. [13] proposed the idea of HierTrain that benefits from hybrid parallelism to use the capacity of the different workers. They proposed a method that finds an optimized dividing position of the model between the workers and is also able to divide the input data in terms of batches with different sizes between the different levels of the hierarchy. Their method is able to reduce the latency of execution with respect to the full-cloud framework; however, it compromises the privacy of the users. The hybrid parallelism method sends a significant amount of raw input data directly to the cloud. Sending this raw data to the higher level workers also increases the communication cost of their method, in addition to the privacy issues. Moreover, this method is vulnerable in the case of network connection failures.

In contrast to these works, our goal is to propose a hierarchical training method that has a low communication cost and respects the privacy of users by not communicating the raw data. This method should be able to exploit the computational potentials of the edge and the cloud at the same time as well.

### _Early Exiting_

Early exiting is a method in DNNs that performs the decision-making in earlier layers in addition to the last layer. In non-hierarchical systems, it has been used in the training
of DNNs in architectures such as GoogLeNet [14] to achieve better accuracy of inference. In these methods, the early exit is used during the training phase and is removed in the inference phase. In hierarchical systems, there are methods such as [15] and [16] that use early exiting to reduce the communication burden of DNN's inference. In these models, the samples that have high confidence levels in the early exit are classified on the edge while the others are sent to the cloud for making the decision.

In contrast, in our work, the focus is on the benefit of early exits to improve the training phase of hierarchical edge-cloud systems. It reduces the latency of the training phase by parallelizing it on the edge and the cloud workers and provides robustness against network failure.

### _Hierarchical Inference_

To be complete on the related studies, we also discuss the hierarchical inference methods. In this group of works, the authors proposed a hierarchical framework for the inference phase of a DNN. Teerapittayanon et al. [15] proposed a distributed computing hierarchy that is made of three levels of cloud, fog and edge where they can execute the inference phase of a DNN when it is separated between them. They benefit from early exiting to reduce the required communication cost between the different levels. After that, Wang et al. [16] proposed adaptive distributed acceleration of DNNs where they proposed a method to select the best position to divide neural networks between the two workers in the inference phase. Recently, Xue et al. [17] proposed a more advanced algorithm that, instead of using iterative approaches to find the best position of separation on hierarchical systems, benefits from the decision-making ability of reinforcement learning to perform the offloading strategy, in systems with complex conditions. Another idea that has been used to reduce the communication cost, relates to using methods of lossy and lossless compression on the communicated data [18].

Although these methods are effective in executing the inference phase on the edge-cloud frameworks, they do not consider the problem of training, which is more complex.

## III Hierarchical Training with Early Exiting

### _Proposed Hierarchical Training Framework_

As mentioned in Section II-A, the idea of training DNNs on a hierarchy of multiple workers is a new area of research that is not yet fully explored. The previous works generally do not exploit the potential of all levels and have high communication cost and privacy concerns. Our method addresses these issues by using the early exiting scheme, that enables a level of parallelism between the edge and the cloud in the different steps of the training phase.

More specifically we divide a conventional DNN architecture between an edge worker and a cloud worker at one of the middle layers, assuming the cloud has higher computational resources in comparison to the edge device, which is often the case (Figure 1-a). In the first step of training (shown in Figure 1-b), the data acquired by the sensor at the edge passes through the layers of the neural network that are located at the edge worker, and the forward pass of the edge is performed. This neural network has two main building blocks: a feature extractor and a local decision maker. The output of the edge feature extractor is transmitted to the cloud to be fed to the rest of the DNN architecture layers. The local decision maker also takes the output of this feature extractor enabling an early exit. The edge loss that is generated in this early exit later allows the neural network parameters at the edge to be updated during the backward pass.

In the second step (shown in Figure 1-c), the feature map, which is generated by the feature extractor at the edge, is communicated to the cloud server. The forward pass of the cloud layers of the DNN is completed, allowing a more computationally intensive feature extraction to take place. Then, the final output generates the cloud loss using the targets. At this time, the backward pass of the edge layer is also done at the edge level for training the parameters of the edge layer. Thus, these two tasks are done in parallel, the backward pass of the edge worker and the forward pass of the cloud worker. In the third step (shown in Figure 1-d), the backward pass of the cloud layers is done to update the parameters of these layers.

In addition to exploiting the potential of both workers simultaneously, an important benefit of this approach is that there is no need to perform any communication during the backward pass, contrary to the previous works (e.g., [13]). The backward pass of each worker is done independently, resulting in a significant reduction in communication cost and total runtime. Indeed, the edge worker only transmits data and does not need to have the receiving ability. Thus, a less complex communicator device is required at the edge which is favorable in practice.

Another benefit of this method is that, as no backward pass happens in the position between the edge and the cloud, non-differentiable functions can be applied to the feature map to further compress it before communication. For example, the activations can be quantized before communicating to the cloud server, reducing the communication burden. These lossy compression methods should however be implemented while considering their possible penalty on the total accuracy.

The training phase is done for the number of iterations that is selected by the user. After finishing it, the inference phase is done on the proposed edge-cloud framework. The steps of the inference phase are simply the forward pass in the edge, the communication of the feature map to the cloud, the forward pass of the cloud and the decision making using the final exit on the cloud. It is worth mentioning that the early exit at the edge device can be also used as a local decision maker in case of network failures.

### _Runtime Analysis_

One of the main goals of this work is to improve the overall runtime of the training phase in our proposed hierarchical training method in comparison to the full-cloud training. This target can be achieved by splitting a neural network at a suitable point between the edge and the cloud, based on the performance of the devices, the selected communication protocol, and the selected DNN architecture. However, the training runtime cannot be estimated easily without physically
implementing it on the devices. The reason is the different choices for the devices and the different internal structures and delays that result in different overall runtimes. To tackle this issue, we propose a method to simplify this procedure and estimate the runtime by just performing one epoch of forward pass on the selected edge and the cloud. We use this forward pass runtime to estimate the runtime of the backward pass. We also calculate the runtime of the update phase and communication phase and propose a method to sum them up to compute the estimated training runtime.

We propose Equation 1 to estimate the training runtime of our proposed hierarchical training method.

\[\begin{split} T_{\text{total}}^{\text{\,biererachical}}=T_{\text{ comp,fow}}^{\text{\,edge}}+\max\left(\left(T_{\text{common}}^{\text{\,biererachical}}+\right. \right.\\ \left.T_{\text{comp,fow}}^{\text{\,cloud}}+T_{\text{comp,hackw}}^{ \text{\,cloud}}\right),T_{\text{comp,backw}}^{\text{\,edge}}\right)\end{split} \tag{1}\]

where \(T_{\text{total}}^{\text{\,biererachical}}\) is the total runtime, \(T_{\text{comp,fow}}^{\text{\,edge}}\) and \(T_{\text{comp,backw}}^{\text{\,edge}}\) are the runtimes of the forward pass and the backward pass of the edge part of the DNN architecture, \(T_{\text{comp,fow}}^{\text{\,cloud}}\) and \(T_{\text{comp,backw}}^{\text{\,cloud}}\) are the runtimes of the forward pass and the backward pass of the cloud part of the DNN architecture and \(T_{\text{comm}}^{\text{\,biererachical}}\) shows the duration of communication between the edge and the cloud. The \(\max\) function reflects that, in our proposed hierarchical training method, the backward pass in the edge is executed at the same time as the communication and execution on the cloud.

Only one forward pass is done on the connected edge and cloud to measure the values of \(T_{\text{comp,fow}}^{\text{\,edge}}\) and \(T_{\text{comp,fow}}^{\text{\,cloud}}\). Afterwards, we calculate the backward pass runtime terms in Equation 1 as

\[T_{\text{comp,backw}}^{\text{\,edge}}=\alpha\ T_{\text{comp,fow}}^{\text{\,edge }}+\beta\sum_{i=1}^{e}\frac{P_{i}}{S^{\text{\,edge}}}, \tag{2}\]

\[T_{\text{comp,backw}}^{\text{\,cloud}}=\alpha\ T_{\text{comp,backw}}^{\text{\, edge}}+\beta\sum_{i=e+1}^{c}\frac{P_{i}}{S^{\text{\,cloud}}}. \tag{3}\]

In Equation (2) and (3), the first term shows the time which is needed to perform calculations of the backward pass. We calculate this by multiplying the backward to forward ratio \(\alpha\) by the measured forward pass runtime. In general, the scaler \(\alpha\) is a value that for most of DNNs with convolution layers and large batch sizes is close to \(2\)[8]. The second term shows the update phase duration and the summations indicate all the layers that are implemented at the edge or the cloud, where \(e\) represents the last layer that is executed on the edge and \(c\) is the total number of layers in the DNN. \(P_{i}\) represents the number of parameters in layer \(i\) that should be updated. \(S\) indicates the theoretical performance (computation speed) of each of the edge and the cloud devices. The scalar \(\beta\) shows the number of FLOPs that are needed to update every parameter of the DNN using the selected optimizer. As an example,

Fig. 1: a) A schematic view of the different parts in the proposed hierarchical execution framework. b) In the first step of training, the forward pass is done at the edge feature extractor to generate the feature set that is sent to the cloud. A local decision maker also takes the output of this feature extractor enabling an early exit that is later used for the backward pass at the edge. c) The feature set is communicated to the cloud and a more computationally intensive feature extraction and the final decision making is done at the cloud. Simultaneously, the backward pass of the edge is done to train the edge parameters. d) The backward pass of the cloud is done to update the cloud parameters. The green borders indicate the running process at each step.
stochastic gradient decent requires \(2\) FLOPs per parameter and Adam optimizer [19] requires \(18\) FLOPs per parameter [8], that results in \(\beta=2\) or \(18\) for these cases.

The communication duration in Equation (1) can be calculated as

\[T_{\text{comm}}^{\text{hierarchical}}=\frac{D_{\text{comm}}}{S_{\text{network}}} \tag{4}\]

where \(D_{\text{comm}}\) is the size of data that is communicated. For our proposed method of hierarchical training, it is the size of the feature map that is communicated. \(S_{\text{network}}\) represents the bandwidth of the selected communication network.

In this study, we compare our work with the full-cloud training method as the baseline. In this case, the edge device just captures the inputs and transmits them to the cloud and the whole training procedure for all layers of the DNN is done on the cloud. The runtime of the full-cloud method is simply calculated as

\[T_{\text{total}}^{\text{fullcol}}=T_{\text{comm}}^{\text{fullcol}}\ +T_{\text{comp, \text{for}}}^{\text{cloud}}+T_{\text{comp,\text{backw}}}^{\text{cloud}}. \tag{5}\]

The backward pass term of Equation (5) can be similarly calculated with one forward pass runtime measurement by exploiting Equation (3). The communication term of Equation (5) can also be calculated with Equation (4). The only difference is the \(D_{\text{comm}}\) that is now the size of the raw input data that is communicated to the cloud.

### _Separation Point Selection_

In the proposed hierarchical method, selecting the position of the separation point of the DNN between the edge and the cloud is important as it can affect the computational and memory burden on the edge and the cloud, the total runtime, and the accuracy. In this section, we propose an algorithm to select the edge-cloud separation position based on user requirements. As the full training of DNNs is computationally heavy, it is highly demanding to try all possible splitting points. Hence, the proposed algorithm smartly confines the splitting point candidates in order to lower the number of full-training trials. The user requirements may contain a maximum possible number of parameters at the edge (memory), a maximum duration of training (runtime), and a minimum precision (accuracy).

We propose Algorithm 1 for this purpose. The algorithm benefits from Equations (1)-(4) to reduce the number of full-training iterations needed on different separation points and to finally find a good position of separation. It finds the desired separation point for the given hardware specifications.

```
0: DNN, Available Edge Memory, Speed of Computation (edge and cloud) and Communication, Accepted Runtime, Accepted Accuracy
0: Position of Separation \(P\) Initialization :
1:\(L^{i}|i=1:N\) : layers/blocks in the DNN
2:\(S_{1},S_{2},S_{3}\leftarrow\emptyset\) Loop 1 :
3:for\(L^{i}|i=1:N\)do
4: Measure\(M_{\text{edge}}^{i}\) by counting parameters at the edge
5:if\(M_{\text{edge}}^{i}<\text{Available Edge Memory then}\)
6:\(S_{1}\).append\((i)\)
7:endif
8:endfor
9:Loop 2 :
10:for\(j\in S_{1}\)do
11: Calculate\(T_{\text{hierarchical,calc}}^{j}\) by Eq. (1)-(4)
12:if\(T_{\text{hierarchical,calc}}^{j}<\text{Accepted Runtime then}\)
13:\(S_{2}\).append\((j)\)
14:endif
15:endif
16:endfor
17:\(S_{3}\leftarrow\text{sort}\ \{S_{3}|\text{in descending order on}\ m,m\in S_{3}\}\)
18:Loop 4 :
19:for\(n\in S_{3}\)do
20: Train DNN for the rest of epochs
21:if\(Acc_{\text{hierarchical,exp}}^{n}>\text{Accepted Accuracy}\)then
22:\(P\gets n\)
23:break
24:endif
25:endfor
26:return\(P\)
```

**Algorithm 1** Selecting the position of separation of DNN between the edge and the cloud with specific runtime and accuracy criteria.

The algorithm inputs are the DNN architecture, the memory of the edge device, the computational power of the edge and cloud devices, the communication speed between the edge and the cloud and the accepted runtime and accuracy selected by the user. In Loop 1, we consider the memory requirement. We simply measure the number of parameters when the architecture is separated on different points. We add the separation points that satisfy the user's edge memory criterion to set \(S_{1}\).

In Loop 2, we compute the runtime based on Equations (1)-(4) for each possible separation point in \(S_{1}\). If for a separation point, the calculated training time is less than the acceptable criterion (\(T_{\text{hierarchical,calc}}^{j}<Accepted\ Runtime\)), it is added to set \(S_{2}\). As we mentioned in Section III-B, it is required to measure the time of just one forward pass before doing these calculations.

In Loop 3, the network is trained for one epoch for these separation points at Set \(S_{2}\) to measure the experimental runtime \(T_{\text{hierarchical,calc}}^{l}\). If the experimental runtime is acceptable for a separation position, it is added to set \(S_{3}\). Afterwards, \(S_{3}\) is sorted based on the separation points, from the deeper to earlier separation positions. The reason for this strategy is that we observe that the deeper separation positions provide better accuracy. It will be shown in the experiments in the next sections.

In Loop 4, the network is trained for the rest of the epochs to
calculate the accuracy for the separation points selected from the sorted Set \(S_{3}\). If the accuracy is higher than the accepted value, the separation point is reported and the procedure is finished; otherwise, the next separation position from the set is selected and the same procedure is repeated. Notice that, in order to measure the accuracy, there is no way but to train the network completely; however, our method requires a low effort to achieve this goal by doing it on a carefully confined and sorted set.

In this algorithm, the full training just exists in Loop 4, after we limit the size of possible candidate separation points in Loop 1 by a measurement of parameters' size and in Loop 2 by a calculation of estimated runtime. Moreover, in Loop 3, we again reduce the size of possible separation points by performing only 1 epoch of training. This often results in few splitting points left to be fully trained in Loop 4. The Loop 4 also might not be done completely since we sorted the set of possible separation points for the loop in a way that there is a higher chance to achieve the required accuracy in the first iteration.

It is worth mentioning that Algorithm 1 can be modified easily for simpler scenarios. For example, when the user has no accuracy requirements, the only difference is that Loop 4 should be removed and all the separation points of Set \(S_{3}\) are acceptable, or when the user has no memory criterion, Loop 1 should be omitted.

In the next section, we perform experiments to validate the benefits of the proposed hierarchical training method.

## IV Experiments

In this section, we elaborate on the hierarchical training framework for different DNN architectures, describe the experiments performed using the proposed hierarchical training method and report the results. These particular DNN architectures are selected as they are widely used in vision tasks, and they are relatively intensive in terms of resource requirements which makes them challenging to run on low-resource devices.

### _Hierarchical Models_

Figure 2 shows VGG-16 [1] architecture implemented in a hierarchical fashion. In this figure, the network is divided between the edge and the cloud after the third convolution layer. This position of separation can however be moved along all layers based on the user's requirements.

The output of early exit provides the loss for the backward pass in the edge and the final output for the cloud provides the loss for the backpropagation of the cloud. The important point here is that most of the conventional DNN architectures such as VGG are not designed to be hierarchically executed. As a result, after most of the layers, the size of the feature map is large, even in comparison to the original input image which makes them expensive to communicate over the network. This

Fig. 3: The structure of the proposed hierarchical training method applied on ResNet-18 architecture [2]. The position of separation can be moved along the different residual blocks of the architecture.

Fig. 2: The structure of the proposed hierarchical training method applied on VGG-16 architecture [1]. The position of separation can be moved along the different layers of the architecture.
increase in the communication cost is not desirable in the hierarchical execution of DNNs. In order to address this issue, a compression convolution layer and a quantizer are used at the division point which reduce the size of the feature map before sending it to the cloud. In our experiments, a \(4\)-bit quantization is used. This bit width is the maximum value that provides a lower communication burden for all the possible separation points of our DNNs, in comparison to the full-cloud training.

Since the range of the feature map may change significantly during the training phase [20], for every quantized batch that is sent to the cloud, one full precision scale value is also communicated [21]. The scale value is calculated as the difference between the maximum value and the minimum value in that batch of data divided by the maximum quantization level (\(2^{4}-1=15\) in our case). The minimum value is \(0\) since ReLU activation functions are used. All the members of the batch are divided by this scale and then quantized before communicating to the cloud. The scale is also communicated to the cloud and is multiplied by the values of the batch there again. This single scale for every batch has a negligible impact on the communication cost, but a significant role in covering the data range to keep the total accuracy high during the different training iterations. Finally, in order to avoid a high memory burden for the edge worker, only one fully connected layer is used in the early exit.

The same form of hierarchical implementation is applied on ResNet-18 [2] architecture. Figure 3 shows the proposed structure. There is again the compression convolution and the quantizer, and the edge-cloud separation can be done after every residual block in this network.

It is worth mentioning that the two DNN architectures of VGG-16 and ResNet-18 are analyzed in this study as they are relatively large models that cannot be easily trained on low-resource devices and the results can represent a large group of convolutional neural network and residual network models that are widely in use in vision systems.

Fig. 4: The test accuracy of experiment on CIFAR-10 for hierarchical training when it is separated on different positions along the architecture compared to the full-cloud training accuracy. The left figure shows the results for VGG-16 and the right figure shows the results for ResNet-18. In addition to the main accuracy, the edge-only test accuracy is also presented as a side benefit of the proposed method. Although this accuracy is lower in comparison to the hierarchical training, it shows how the edge handles the classification problem alone when there is a possible communication failure.

Fig. 5: The number of parameters of the deep neural network in the edge side and the cloud side in the hierarchical system when it is separated on different positions along the architecture in comparison to the number of parameters in the full-cloud system. The left figure shows the results for VGG-16 and the right figure shows the results for ResNet-18. Notice the low number of parameters in the edge for most of the separation positions in hierarchical training that is desirable due to the possible memory constraints.
### _Performance Analysis_

In this part, the performance analysis setup is elaborated. We analyze the important performance factors of accuracy, memory footprint, computational burden, communication rate and runtime in our proposed hierarchical training framework and compare the results with the baseline of full-cloud training. The experiments are done on CIFAR-10 dataset [22]. The VGG-16 architecture is trained for \(100\) epochs with Adam optimizer [19] with a learning rate of \(2\times 10^{-4}\). The number of output channels of the compression convolution varies between \(4\) and \(512\) based on the position of the separation point. The ResNet-18 architecture is trained for \(200\) epochs with stochastic gradient descent optimizer and an initial learning rate of \(0.1\) that is reduced through every epoch with a cosine annealing scheduler [23]. Here, the number of channels in the output of the compression convolution varies between \(4\) and \(64\) based on the position of the separation point.

Figure 4 shows the test accuracy of the hierarchically trained DNN when it is separated at different positions along the architecture in comparison to the full-cloud training. For most of the separation points, the accuracy of the final exit of hierarchical training is close to the accuracy of the full-cloud training, even though the backpropagation is not connected between the edge and the cloud, and the information communicated in the forward pass is compressed. As a side benefit, the test accuracy of the early exit in the edge is shown. Although this accuracy is lower in comparison to the hierarchical cloud, it shows that our proposed method can also provide a level of robustness against network failures, as the edge can still handle the classification problem up to an acceptable accuracy on its own. As an example, at separation position 3, our proposed hierarchical training method provides \(89.29\%\) accuracy for the VGG-16 architecture in the final exit that is close to the accuracy of \(91.86\%\) in the baseline full-cloud training. The early exit of our proposed hierarchical training method is able to provide \(85.49\%\) on its own in case of a communication

Fig. 6: The computational cost of the deep neural network in terms of MACC in the edge side and the cloud side during the hierarchical training when it is separated in different positions along the architecture in comparison to the computational cost of the full-cloud training. The left figure shows the results for VGG-16 and the right figure shows the results for ResNet-18. Notice the low computational burden in the edge for many of the separation points in hierarchical training that makes them desirable as the computational power is often constrained.

Fig. 7: The required communication burden in terms of bits by the proposed hierarchical training when it is separated in different positions along the architecture compared to the full-cloud training that directly sends the original inputs to the cloud. The left figure shows the results for VGG-16 and the right figure shows the results for ResNet-18. The proposed hierarchical training approach has a lower communication burden in comparison to the full-cloud training that communicates the original inputs.
failure which is an acceptable accuracy.

Figure 5 shows the number of parameters of the DNN that exists in the edge and the cloud. These values are obtained by counting the parameters on both hierarchical and full-cloud training models when the DNN is implemented. The important point in these figures is that, for many of the separation points, especially the ones in the earlier layers, the number of parameters in the edge is significantly lower in comparison to the number in the full-cloud model. As an example, at the separation point 3, there are just \(1.73\times 10^{5}\) parameters implemented at the edge for our proposed hierarchical training method for VGG-16 architecture while this value is equal to \(1.53\times 10^{7}\) for the full-cloud training. This result is desirable in edge-cloud frameworks since the memory of the edge is usually confined.

Figure 6 shows the computational burden of hierarchical training of DNNs in the edge and the cloud in comparison to the full-cloud training in terms of multiplications and accumulations (MACC). The value is measured by counting all the MACC operations in each of these models, on each device. The crucial point is that the computational burden of the edge is significantly low for many of the separation positions, especially in the earlier separation points. For example, there are only \(1.90\times 10^{8}\) MACC operations at the edge in the VGG-16 architecture in our proposed hierarchical training method, while there are \(9.58\times 10^{8}\) MACC operations in the baseline full-cloud training for this architecture. This is favorable for the edge-cloud systems since there are often restrictions in the computational resources of the edge devices which may cause high latency. As a side benefit, one can see that in all separation points, the computational burden of the cloud is also lower in comparison to the full-cloud training, which provides a lower cost of cloud services.

Figure 7 shows the communication requirement of the proposed hierarchical training method in comparison to the full-cloud training. This value is the measured size of the quantized feature maps and the scales that are communicated in the hierarchical training model and the raw images that are communicated in the full-cloud model. As it is shown in these figures, for all of the separation points, this communication burden is lower in comparison to the full-cloud training as this method does not communicate in the backward pass, and compresses the information that is sent to the cloud in the forward pass. For example, at separation point 3, \(16384\) bits are communicated during the proposed hierarchical training method in VGG-16 architecture, while in the baseline full-cloud training, \(24576\) bits are communicated. In this experiment using our proposed hierarchical training method, we choose the number of channels of the compression convolution in such a way that the size of the output feature map stays less than a predefined fixed value, that results in almost flat curves.

The next important performance factor is the training runtime. As improving the runtime of training is a main goal of our proposed hierarchical training method, we should have a good estimation of this value to know where to separate a DNN architecture between the edge and the cloud (See Section III). In Section III-B, we proposed a set of equations to estimate the runtime of training. In this part, we evaluate their performance by experimenting on a system of two devices, made of NVIDIA Quadro K620 [24] (edge) and NVIDIA GeForce RTX 2080 Ti [25] (cloud). As mentioned before, we perform a simple forward pass runtime measurement, then we use Equations (1)-(3) to estimate the training runtime. We perform this for different separation positions and compare the estimated runtime with the experimental runtime on two devices. The devices are directly connected in this simplified experiment; consequently, the communication term of Equations (1) is negligible.

Figure 8 shows the result of this experiment. It shows that our calculation method can provide a good estimation of runtime for different separation points along the DNN architectures, and it can be used for separation point selection (see Section III-C). It is worth mentioning that for the VGG-16 experiment, the selected edge device memory could not handle the separation points after the point 7; as a result, they do not exist in Figure 8.

Using Equations (1)-(5) from Section III-B and the accuracies that have been measured in Section IV Figure 4, we

Fig. 8: The calculated runtime of one epoch of training in different positions along the architecture in comparison to the experimental values, for the proposed hierarchical training framework implemented on a simplified edge-cloud system. The left figure shows the results for VGG-16 and the right figure shows the results for ResNet-18. Our calculation method can provide a good estimation of the experimental values for most of the points.
obtain the guide Figure 9. This figure shows the accuracy versus calculated training runtime for the different separation positions on the neural networks (the separation positions are shown by the point labels) for our proposed hierarchical training method in comparison to the full-cloud training baseline. These values are computed for 3G and 4G communication protocols between edge and cloud. 3G and 4G are selected as these networks have covered \(94.9\%\) and \(85.0\%\) percent of the world population respectively according to to [26] and can be used for hierarchical systems.

The figures show that for both VGG-16 and ResNet-18 architectures and both 3G and 4G communication protocols, our proposed method can provide a good reduction in the runtime, while the penalty on accuracy is low for many of the separation points. The gain in runtime is higher when 3G communication protocol is used since the communication bandwidth is lower and reducing its burden can have a more significant effect on the total runtime. These figures help to choose the best hierarchical division between the edge and the cloud based on the specific accuracy and runtime requirements of the user. Remind that the Figures 5 and 6 also help the user to satisfy the memory footprint and the computational cost requirements.

### _On-Device Experiments_

In this section, we demonstrate the performance of the proposed hierarchical training method with on-device experiments. In this setting, the edge device has a low-resource NVIDIA Quadro K620 [24] with \(863.2\) GFLOPS theoretical performance and the cloud has a high-end NVIDIA GeForce RTX 2080 Ti [25] with \(13.45\) TFLOPS theoretical performance. For the data communication stage, we simulate two different telecommunication protocols, 3G and 4G. Notice that in these setups, the data transfer bottleneck is the upload link which has an average speed of \(1.1\) Mbps for 3G and \(5.85\) Mbps for 4G in the United States [12].

Table I shows the results of experiments for VGG-16 and ResNet-18. The computational runtime results and the final accuracies are also added to Table I for the sake of comparison. For these experiments, the separation position 3 has been selected for both architectures as it provides a good balance between the accuracy, the edge memory, the computational cost and the runtime (see Figures 4-9). As it is shown, for the two different DNNs and the telecommunication technologies, the hierarchical training scenarios provide a lower runtime in comparison to the full-cloud systems whilst having a marginal reduction in the accuracy. In 3G communication, it results in \(28.96\%\) improvement for VGG-16 and \(60.91\%\) for ResNet-18 in terms of runtime. For 4G communication, the improvements are \(13.78\%\) for VGG-16 and \(36.26\%\) for ResNet-18. As expected, the proposed hierarchical method is more advantageous for less efficient communication links since generally, the communication link is the bottleneck of the overall efficiency of the hierarchical systems. Moreover, it is shown that our calculations generally provide a good estimation in comparison to the experiments. The calculated values are slightly different compared to the experimental ones, due to the complexities that exist in the real devices and experiments that are not counted in our simplified calculations, like the overhead for the communication between different parts inside a single GPU.

## V Summary and Future Works

In this study, a novel hierarchical training approach for DNN architectures in edge-cloud scenarios has been proposed. It provides less communication cost, lower runtime, higher

Fig. 9: The accuracy and the calculated runtime of the proposed hierarchical training method when it is separated in different positions along the architecture in comparison to the full-cloud training. The label numbers show the positions of separation points. Left: The 3G communication protocol is considered. Right: The 4G communication protocol is considered.
privacy for the user, and improved robustness against possible network failures compared to the full-cloud training. We performed simulations on different neural network architectures and implemented the proposed approach on a two-device framework and validated its superiority with respect to the full-cloud training.

In the domain of hierarchical training of neural networks, a further topic to investigate is the design of hierarchical-friendly neural network architectures. As we saw in this study, the available DNN architectures are not made to be executed hierarchically. They have issues like the larger size of intermediate feature maps in comparison to the inputs, which reduces the effectiveness of hierarchical training approaches. New neural network architectures could be developed that inherently consider this issue. They could also take into account other important points such as keeping a low computational cost in the parts that are executed on the edge.
