# An End-to-End Video Steganography Network Based on a Coding Unit Mask
## 2 Proposed End-to-End Video Steganography System
### Training
#### 2.2.1 Loss Function  
The encoder, decoder and discriminator are integrated together for end-to-end training. As shown in Figure 1, the loss functions are set reasonably and are minimized by gradient back propagation and update of the model parameters. After multiple rounds of training on the dataset, the encoder and decoder models with updated parameters are obtained, which are applied to the sender and receiver of secret messages, respectively.  
The red dotted line in Figure 1 indicates three loss functions for network training. (1) Message extraction loss (\(L_{m}\)) in Formula (1) uses cross-entropy loss. The lower the bit  
Figure 6: The discriminator component of PyraGAN.  
error rate between the extracted message \(\mathbf{M_{ext}}\) and embedded message \(\mathbf{M_{emb}}\), the smaller this loss.  
\[L_{m}=CrossEntropy(\mathbf{M_{emb}}\,\mathbf{M_{ext}}) \tag{1}\]  
(2) Video reconstruction loss (\(L_{e}\)) in Formula (2) uses the mean square error (MSE), where \(C\), \(H\), and \(W\) represent the channel, height, and width of one video frame, respectively, and \(\mathbf{V_{(k,i,j)}}\) represents the pixel value at channel \(k\), row \(i\), and column \(j\) of the video frame. The more similar the stego video frames and cover video frames, the smaller this loss.  
\[L_{e}=MSE\big{(}\mathbf{V_{cover}},\mathbf{V_{stego}}\big{)}=\frac{1}{C\times H\times W }\sum_{k=1}^{C}\sum_{i=1}^{H}\sum_{j=1}^{W}\big{(}V_{cover(k,i,j)}-V_{stego(k,i,j)}\big{)}^{2} \tag{2}\]  
(3) Adversarial (generator) loss in Formula (3) uses Wasserstein [35] distance to characterize the degree of overlap between the distribution of stego frame \(\mathbf{V_{stego}}\) and that of the cover frame \(\mathbf{V_{cover}}\) where \(\sigma\) represents the discriminator and \(E\) represents the expectation of the distribution function. \(P_{stego}\) is the data distribution of the stego frame. \(P_{cover}\) is the data distribution of the cover frame.  
\[\max_{\sigma}\min_{\varepsilon}L\big{(}\mathbf{V_{cover}},\mathbf{V_{stego}}\big{)}=E_ {x\sim P_{stego}}\sigma(x)-E_{x\sim P_{cover}}\sigma(x) \tag{3}\]  
The generator needs to minimize the Wasserstein [35] distance so that the stego video frames can be confused with the cover frames. When training the generator, the discriminator parameters are fixed, and the latter of Formula (3) has nothing to do with the generator, so the generator loss (\(L_{a}\)) adopts what is shown in Formula (4), where \(\varepsilon\) represents the encoder. When training the discriminator, the generator parameters are fixed. The discriminator should be enough to distinguish the \(\mathbf{V_{stego}}\) and the \(\mathbf{V_{cover}}\), so it should maximize the Wasserstein [35] distance, i.e., minimize its opposite. Therefore, the adversarial loss (\(L_{d}\)) is shown in Formula (5).  
\[L_{a}=E_{x\sim P_{stego}}\sigma(x)=E_{x\sim P_{stego}}\sigma(\varepsilon(\mathbf{ V_{cover}},\mathbf{M_{emb}})) \tag{4}\]  
\[L_{d}=E_{x\sim P_{cover}}\sigma(x)-E_{x\sim P_{stego}}\sigma(x) \tag{5}\]  
During each round of training, the discriminator and encoder-decoder network are trained alternately. First, the discriminator is trained to optimize the parameters by minimizing the loss \(L_{d}\) in Formula (5). Then, the encoder-decoder network is jointly trained to update its parameters by minimizing the total loss \(L_{g}\), as shown in Formula (6). \(\lambda_{1}\), \(\lambda_{2}\), and \(\lambda_{3}\) are the weight coefficients of message extraction loss \(L_{m}\), video reconstruction loss \(L_{e}\), and generator loss \(L_{a}\), respectively.  
\[L_{g}=\lambda_{1}\times L_{m}+\lambda_{2}\times L_{e}+\lambda_{3}\times L_{a} \tag{6}\]