# Arbitrary Motion Style Transfer via Contrastive Learning
## 3 Methodology
### Training  
Our framework adopts an end-to-end encoder-decoder architecture. The training process involves the following details and loss computation. **Motion reconstruction loss. ** We compute the reconstruction motion \(M_{s}^{rec}\) by applying the generator function \(G(M_{s},M_{s})\) to the input content motion \(M_{s}\). We then compare \(M_{s}^{rec}\) and \(M_{s}\) using the L1 loss, measuring the absolute difference between corresponding elements of the two sequences. We calculate the loss in both the input style motion \(M_{s}\) and the content motion \(M_{c}\). \[ \begin{split}\mathcal{L}_{rec}&=\left\lVert M_{s}^{ rec}-M_{s}\right\rVert_{1}+\left\lVert M_{c}^{rec}-M_{c}\right\rVert_{1}\\ M_{s}^{rec}&=G(M_{s},M_{s})\\ M_{c}^{rec}&=G(M_{c},M_{c})\end{split}  \tag{1}\]  
**Cycle consistency loss. ** Cycle consistency loss ensures that the generated motion can be accurately translated back to the source motion. This mechanism enhances the generator's ability to maintain consistency and coherence by enforcing the mapping to be bijective, enabling the generated motion to faithfully represent the original source motion [10]. \[ \begin{split}\mathcal{L}_{cyc}&=\left\lVert M_{s}^{ cyc}-M_{s}\right\rVert_{1}+\left\lVert M_{c}^{cyc}-M_{c}\right\rVert_{1}\\ M_{s}^{cyc}&=G(M_{sc},M_{s})\\ M_{c}^{cyc}&=G(M_{c},M_{sc})\end{split}  \tag{2}\]  
**Contrastive learning loss. ** We have incorporated two types of contrastive learning techniques into our model. The first approach focuses on establishing difference between the generated motion and other motions. Specifically, it associates the generated motion with the input motion, ensuring that both belong to the same category while differing from others [23]. This enables the model to learn the similarity between the positive pair, denoted as \(\mathbf{z}^{+}\) and \(\mathbf{z}\), while enhancing the ability to distinguish other contrastive motion codes \(\mathbf{z}^{-}\). \[ \begin{split}\mathcal{L}_{\text{contra}}&=\mathcal{L}_{\text{s- contra}}+\mathcal{L}_{\text{c-contra}}\\ \mathcal{L}_{\text{s-contra}}&=-\log\frac{\exp(\mathbf{z }_{s}\cdot\mathbf{z}_{s}^{+}/\tau)}{\exp(\mathbf{z}_{s}\cdot\mathbf{z}_{s}^{ +}/\tau)+\sum\exp(\mathbf{z}_{s}\cdot\mathbf{z}_{s}^{-}/\tau)}\\ \mathcal{L}_{\text{c-contra}}&=-\log\frac{\exp( \mathbf{z}_{c}\cdot\mathbf{z}_{c}^{+}/\tau)}{\exp(\mathbf{z}_{c}\cdot\mathbf{ z}_{c}^{+}/\tau)+\sum\exp(\mathbf{z}_{c}\cdot\mathbf{z}_{c}^{-}/\tau)}\end{split}  \tag{3}\]  
where \(\cdot\) represents the dot product of two vectors. \(\tau\) is a temperature hyper-parameter per. Additionally, we adopt a memory bank architecture inspired by [PERSON] et al. [36], which acts as a dynamic queue storing embeddings of negative samples. This architecture allows the model to efficiently access diverse negative examples during training, enhancing the discriminative power of contrastive representations. Specifically, we maintain separate memory banks for style and content features, each with a fixed capacity of 512 entries updated via a first-in-first-out (FIFO) strategy. The second contrastive learning technique involves the use of two different random temporal motion clips, denoted as \(\tilde{M}\) and \(\tilde{M}\), from the same motion sequence. This pairing serves as a positive example, explicitly enhancing the model's ability to compare stylistic details across multiple time scales. \[ \begin{split}\mathcal{L}_{\text{temp-contra}}&= \mathcal{L}_{\text{s-temp-contra}}+\mathcal{L}_{\text{c-temp-contra}}\\ \mathcal{L}_{\text{s-temp-contra}}&=-\log\frac{ \exp(\hat{\mathbf{z}}_{s}\cdot\hat{\mathbf{z}}_{s}/\tau)}{\exp(\hat{\mathbf{z }}_{s}\cdot\hat{\mathbf{z}}_{s}/\tau)+\sum\exp(\hat{\mathbf{z}}_{s}\cdot\mathbf{ z}_{s}^{-}/\tau)}\\ \mathcal{L}_{\text{c-temp-contra}}&=-\log\frac{ \exp(\hat{\mathbf{z}}_{c}\cdot\hat{\mathbf{z}}_{c}/\tau)}{\exp(\hat{\mathbf{z }}_{c}\cdot\hat{\mathbf{z}}_{c}/\tau)+\sum\exp(\hat{\mathbf{z}}_{c}\cdot\mathbf{ z}_{c}^{-}/\tau)}\end{split}