# Auto-Encoder Learning-Based UAV Communications for Livestock Management
## 3 Proposed Methodology  
Generally, a simple communications system can be viewed as a particular type of auto-encoder from the deep learning viewpoint [30; 33]. An auto-encoder is an unsupervised learning model that learns to squeeze and reconstruct the input. Therefore, it can be considered a dimensionality reduction framework that allows the input reconstruction at the output with minimal error. However, in our case, the auto-encoder is used for end-to-end communication to learn the representations of the messages \(s\) that are robust to the channel impairments mapping \(\mathbf{x}\) to \(\mathbf{y}\), such that the transmitted information can be recovered with a minimal probability of error. Contrary to redundancy removal from the input data for compression, our proposed auto-encoder usually adds redundancy, learning an intermediate representation robust to channel variations for reliable data transfer. Firstly, the UAV flies above the livestock to capture data (usually real-time images) about the livestock and send it to the GCS for analysis. The reliable data transfer requires that the UAV communication system be divided into a sequence of communication blocks, which are traditionally optimized individually. Such an approach depends on complex mathematical models that are usually intractable. However, the communication blocks are jointly optimized as a single learning block to simplify the process while ensuring reliable data transfer from the UAVs to the GCS. The proposed auto-encoder is shown in Figure 3. Here, the transmitter, which could be a UAV, is the encoder consisting of feedforward convolutional neural network (CNN) layers followed by a normalization layer that guarantees that the physical constraints on \(\mathbf{x}\) are met based on (2) or (3). Accordingly, the input \(s\) to the encoder is encoded as a one-hot vector \(\mathbf{1}s\in\mathbb{R}^{M}\), having an \(M\)-dimensional vector, the \(s\)-th element of which is equal to one and zero otherwise. The wireless channel layer is represented by a fading channel obtained from a random normal distribution with zero mean and unit variance and an Additive White Gaussian Noise (AWGN). Similarly, the receiver (decoder), which could be the GCS, is also implemented as a feedforward CNN. The decoder's final layer uses a softmax activation whose output \(\mathbf{p}\in(0,1)^{M}\) is a probability vector over all possible messages. The estimated message corresponds to the index of the element of \(\mathbf{p}\) with the highest probability value. Consequently, the conditional probability density function \(\mathbf{p}(\mathbf{y}|\mathbf{x})\) defines the channel, where \(\mathbf{y}\in\mathbb{R}^{2n}\) designates the received signal. Once \(\mathbf{y}\) is received, the decoder applies the transformation \(g:\mathbb{R}^{2n}\rightarrow\mathbb{M}\) to yield the estimate of the transmitted message \(\delta\). We train the auto-encoderend-to-end using stochastic gradient descent (SGD) over all possible messages \(s\in\mathbb{M}\) using the appropriate categorical cross-entropy loss function to generate the predicted output or reconstructed estimate of the transmitted message. Therefore, the loss function is given by  
\[\mathcal{L}(\theta)=-\frac{1}{N}\sum_{i=1}^{N}s_{i}\log\left(s\right), \tag{5}\]  
where \(N\) is the number of samples, \(\theta\) is the model parameters (weights of the neural network), \(s\) is the original transmitted message, and \(\hat{s}\) is the estimated message. Accordingly, this end-to-end learning concept is applied to UAV communications, where information about herds (usually images) from the UAVs is sent through a wireless channel to the GCS for effective monitoring. The details of the proposed auto-encoder UAV communications system are shown in Figure 4, and its architectural layout is provided in Table 1.