# Mitigating Digital Ageism in Skin Lesion Detection with Adversarial Learning
## 3 Methods
### Training Deep VAE Model for Fairness  
Previous works aimed at learning fair representations via adversarial learning primarily focused on tabular data [14; 31] or low-resolution images [25; 32]. However, when dealing with high-resolution medical images, such as those used in skin lesion detection, directly applying traditional variational autoencoders (VAE) can introduce several challenges. First, high-resolution images typically contain a large amount of pixel-level detail, resulting in a high-dimensional input space. Training a model on such data can become computationally expensive and difficult due to the increased complexity and dimensionality of the input [33]. Second, traditional VAE architectures often struggle to capture the fine-grained details that are critical for the accurate classification and diagnosis of skin lesions. The loss of this crucial information during encoding can negatively impact the model's performance, leading to suboptimal predictions. Therefore, specialized architectures and techniques are required to effectively encode high-resolution medical images in a way that preserves essential details while ensuring fairness in the model's predictions. To address these issues, we propose using a deep hierarchical VAE architecture. A deep hierarchical VAE is capable of learning more complex and structured representations of the data by encoding the input at multiple levels of abstraction. This allows the model to capture both coarse- and fine-grained details of the image by progressively refining the latent representation across different layers. By encoding at multiple abstraction levels, the VAE can generate data at different levels of detail by sampling from different layers of the latent representation [33]. This hierarchical structure is particularly beneficial for high-resolution medical images, as it allows for the effective capture of both global and local image features. The Very Deep VAE (VDVAE) uses the hierarchical factorization of the prior and approximate posterior distributions, where \(K\) stochastic layers are employed to progressively capture more complex information from the input data. The factorization of the prior distribution \(p_{\theta}(\mathbf{z})\) and the approximate posterior distribution \(q_{\phi}(\mathbf{z}|\mathbf{x})\) for a model with \(K\) layers are expressed as follows:  
\[p_{\theta}(\mathbf{z}) = p_{\theta}(\mathbf{z}_{0})p_{\theta}(\mathbf{z}_{1}\quad\quad \mathbf{z}_{0})\cdots p_{\theta}(\mathbf{z}_{K-1}\quad\quad\quad\mathbf{z}_{< K-1})p_{\theta}(\mathbf{z}_{K}\quad\quad\quad\mathbf{z}_{<K})\] \[q_{\phi}(\mathbf{z}\mid\mathbf{x}) = q_{\phi}(\mathbf{z}_{0}\mid\mathbf{x}) \tag{9}\] \[\times q_{\phi}(\mathbf{z}_{1}\mid\mathbf{z}_{0},\mathbf{x})\] \[\times\cdots\] \[\times q_{\phi}(\mathbf{z}_{K-1}\mid\mathbf{z}_{<K-1},\mathbf{x})\] \[\times q_{\phi}(\mathbf{z}_{K}\mid\mathbf{z}_{<K},\mathbf{x})\]  
where \(p_{\theta}(\mathbf{z}0)\) is the prior distribution for the latent variable at the first layer, and \(p\theta(\mathbf{z}_{i}\mid\mathbf{z}_{i-1})\) is the conditional prior for each subsequent latent variable, conditioned on the latent variables from previous layers. \(K\) represents the total number of stochastic layers in the model, with each layer refining the latent representation learned by the model. \(\mathbf{z}_{<K}\) represents all latent variables from the layers before layer \(K\), capturing hierarchical information. As depicted in Figure 3, the model comprises both a high-resolution (HR) branch, with dimensions \(1024\times 1204\), and a low-resolution (LR) branch, with dimensions \(28\times 28\). The pooling layer is employed for the downsampling of the HR input and upsampling of the LR input. The distribution \(p_{\theta}(. )\) is modeled as a diagonal Gaussian, \(\mathbf{z}\) is sampled from \(q_{\phi}(. )\), and the group of latent variables \(z_{0}\) is positioned at the top layer, featuring a smaller number of variables for the low-resolution input.