# Deep Learning Entrusted to Fog Nodes (DLEFN) Based Smart Agriculture
## 4 Proposed Solution
### Proposed DLEFN Algorithm  
The proposed DLEFN algorithm defines the optimal DL layers for fog nodes in order to accommodate the maximum number of applications requiring DL services during smart agriculture applications' processing in an FC environment. The proposed DLEFN uses two procedures to accommodate a new DL application, as shown in Figure 6. When a new application with DL tasks is introduced to a given environment, the first procedure of the DLEFN focuses on defining the maximum number of DL layers for each fog node within its available resources. However, if a fog node has insufficient resources to accept even the defined minimum layers, it reduces the number of layers allowed for other DL tasks to guarantee a minimum resource capacity for an attempted task. When even one of the fog nodes has problems caused by insufficient computing capacity and bandwidth, the other procedure of the DLEFN attempts to give opportunity for applications that cause lower burden by comparing the allowed and new applications. The components of DL services grafted onto an FC system are as follows. A set of fog nodes dispersed in an area is denoted by \(F\), and a fog node that belongs to the set is denoted by \(i\) for identification. The given processing capacity on a fog node \(i\) is represented by \(c_{i}^{max}\), which also describes maximum capacity to handle tasks at the same time. The allowed maximum bandwidth for transmission from fog node \(i\) to the cloud is represented by \(b_{i}^{max}\). Each fog node has different processing capacity and network bandwidth according to time or environment of installation, like a real environment. Applications consist of one or more tasks requiring DL service and used by multiple users in various places. A set of DL applications accommodated in FC-based smart agriculture is denoted by \(A\), and an application that belongs to set \(A\) is defined as \(a\). A new application that does not belong the set  
Figure 6: Operational overview of proposed deep learning entrusted to fog nodes (DLEFN) algorithm in DL task deployment architecture. is denoted as \(n\). A set of tasks for an application is denoted by \(T\). Accordingly, application \(a\) and \(n\) have task sets \(T_{a}\) and \(T_{n}\), respectively, and \(t\) denotes a task that belongs to \(T\). \(L_{t}^{total}\) indicates the total number of DL layers for task \(t\). \(l_{t}^{k}\) and \(r_{t}^{k}\), up to the \(k\) th layer \(\left(1\leq k\leq L_{t}^{total}\right)\) for task \(t\), respectively denote the average computing loads per data unit and the average reduction ratio for incoming data. Accordingly, \(d_{t}^{i}\) denotes the average incoming data size per unit time for task \(t\) at fog node \(i\); the required capacity corresponding loads for handling it until the \(k\) th layer is calculated by \(l_{t}^{k}\times d_{t}^{i}\); and the data size after the \(k\) th layer is calculated by \(r_{t}^{k}\times d_{t}^{i}\). Furthermore, we consider transmission delay to guarantee QoS. The allowable maximum transfer delay for task \(t\) is defined by \(Q_{t}\). As stated above, the DLEFN consists of two procedures to enable DL service for a new application. The first procedure attempts to define up to the largest layer to each fog node within its individual available computing capacity and bandwidth. \[L_{tn}^{i}\ =\ \max\left\{ \begin{array}{l}l_{tn}^{k}\times d_{tn}^{i}\leq c_{i} ^{able},\\ k\times\frac{d_{tn}^{i}}{\sum_{i=0}^{k}b_{i}^{able}},\\ L_{t}^{min}\leq k\leq L_{tn}^{total}\end{array} \right\}\quad s.\ t.,\ \ \ tn\in T_{n} \tag{1}\]  
\(L_{tn}^{i}\) is the number of DL layers that handle data for task \(tn\) of new application \(n\) at a fog node \(i\).