## 4 The Proposed TransTLA Method
### Transfer Learning Implementation  
In the field of TL, Domain-Adversarial Training (DAT) and Model-Agnostic Meta-Learning (MAML) are two representative methods. DAT introduces domain discriminators and adversarial training strategies to learn domain invariant feature representations by minimizing the distribution difference between the source and target domains [25]. On the other hand, MAML leverages the concept of meta-learning to train models on a multitude of tasks, enabling them to quickly adapt to new target tasks [26]. TL boosts the efficiency and performance of a target task by transferring knowledge from a source domain. In our study, TL is employed in home appliance sales forecasting, with the aim of leveraging experience from data-rich areas (such as large cities) to enhance the predictive capabilities of the model in data-scar areas (such as small towns). Instead of the traditional two-step process of training on the source domain followed by fine-tuning on the target domain, a composite loss function is utilized during model training. This function comprises the source domain regression loss \(\mathcal{L}_{\text{source}}\), target domain regression loss \(\mathcal{L}_{\text{target}}\), and domain adaptation loss \(\mathcal{L}_{\text{adapt}}\). By leveraging data from both domains, our method progressively adjusts the model for better adaptation to the target domain's predictive tasks. This integrated approach aims to enhance the model's ability to  
Figure 5: The structure of the attention mechanism. generalize across domains without the need for separate adversarial training or extensive meta-learning phases. The calculation of \(\mathcal{L}_{\text{source}}\) and \(\mathcal{L}_{\text{target}}\) focuses on optimizing the prediction performance through mean squared error (MSE) between the model's outputs and actual data in both domains, i.e.,  
\[\mathcal{L}_{\text{source}}=\text{MSE}(y^{\text{source}},y^{\text{source}})= \frac{1}{N}\sum_{i=1}^{N}\left(y_{i}^{\text{source}_{i}}-y_{i}^{\text{source} }\right)^{2} \tag{16}\]  
\[\mathcal{L}_{\text{target}}=\text{MSE}(y^{\text{target}},y^{\text{target}})= \frac{1}{N}\sum_{i=1}^{N}\left(y_{i}^{\text{target}}-y_{i}^{\text{target}} \right)^{2} \tag{17}\]  
where \(y^{\text{source}}\) and \(y^{\text{source}}\) are the actual data and predicted results from the source domain training set, respectively; and \(y^{\text{target}}\) and \(y^{\text{target}}\) are the actual data and predicted results from the target domain training set, respectively. The domain adaptation loss \(\mathcal{L}_{\text{adapt}}\) in home appliance sales forecasting aims to bridge the knowledge gap between source and target domains, facilitating the effective transfer of the model from the source to the target domain by quantifying the similarity of their feature distributions. Maximum Mean Discrepancy (MMD), a widely used measure of distribution similarity based on kernel methods, enables the comparison of distribution differences in high-dimensional spaces [11]. Specifically, MMD is defined as the difference between the means of two probability distributions, \(P\) and \(Q\), given by Equation (18), with a value close to zero indicating alignment and a higher value signifying divergence. Minimizing MMD facilitates effective knowledge transfer, thereby enhancing the model's performance in the target domain. \[\text{MMD}^{2}(P,Q)=\left\|\int\phi(x)dP(x)-\int\phi(x)dQ(x)\right\|^{2} \tag{18}\]  
In Equation (18), \(\phi(\cdot)\) is a mapping function from the input space to some high-dimensional feature space, and \(\|\cdot\|\) denotes the norm in that feature space. In our study, a linear variant of MMD is used as the domain adaptation loss. This specialized MMD variant leverages a linear mapping function, simplifying the computation by utilizing the dot product in the original feature space as the kernel.