# Arbitrary Motion Style Transfer via Contrastive Learning
## 3 Methodology
### Architecture  
**Motion transfer module.** The motion transfer module, denoted as \(G\), includes a style encoder \(E_{s}\), a content encoder \(E_{c}\), and a decoder \(D\). It takes as input a style motion sequence \(M_{s}\) and a content motion sequence \(M_{c}\) to generate the motion \(M_{sc}\).  
The motion sequence \(M\) consists of \(T\) frames, each frame containing quaternion rotations for \(J\) joints \(M\in\mathbb{R}^{T\times J\times 4}\). In temporal dimension, a motion sequence \(M=\{m_{1},m_{2},\dots,m_{t}\},0\leq t\leq T\).  
Our encoder architecture is designed based on the asymmetry encoder framework proposed by [PERSON] et al. [4]. The content encoder comprises multiple residual blocks that are utilized to transform the motion sequence into a suitable manifold space. Moreover, in order to eliminate style information [35], instance normalization (IN) is applied to each residual block. On the other hand, the style encoder consists of same residual blocks without instance normalization, complemented by a three-layer MLP (multilayer perceptron). This MLP is employed to make style code directly modify the means and variances of the content code. Moreover, the style encoder produces fixed-size latent code which is independent on the temporal length of the clip.  
Figure 2: Framework overview. **Up**: The content motion and style motion are separately encoded using a content encoder and a style encoder, then decoded into generated motion. This generated motion, along with the corresponding input motion, undergoes cycle generation within the generator. **Down**: Both the generated motion and the input motion are subjected to contrastive learning in a dedicated module, facilitating style and content contrastive learning.  
The decoder utilizes an adaptive normalization layer (AdaIN) to combine the style code and content code, enabling the reconstruction of the original joint rotations based on the merged latent representation.  
**Contrastive learning module.** The contrastive learning module \(F\) comprises separate encoders and the corresponding contrastive learning projector, which consists of a two-layer MLP. Once the style encoder transforms the motion sequence \(M_{s}\) into style code \(w_{s}\), the projector further converts the style code into contrastive style code \(z_{s}\). As \(z\) is a K-dimensional vector, \(z^{+}\in\mathbb{R}^{K}\) and \(\{z^{-}\in\mathbb{R}^{K}\}\). This process explicitly constructs a contrastive learning space, facilitating the differentiation of various style representations. Similarly, the content encoding undergoes a similar procedure, ensuring the creation of a contrastive learning space for the content representations.  
In addition, we have introduced a random temporal sampler, similar as the augmentation technique discussed in [6]. This sampler randomly selects a segment of the motion sequence \(\hat{M}=\{m_{i},m_{i+1},\dots,m_{j}\},0\leq i,j\leq T\) as input for the contrastive learning module, instead of using the entire source motion sequence, shown in Figure 1. The purpose of this sampler is to facilitate contrastive learning through random temporal clips.