## 5 Methodologies
### Models
#### 5.1.4 RSQGAN Model  
RSQGAN is a cGAN learned by training a conditional generator TCN against a conditional discriminator TCN.  
Let \(J\in\mathbb{N}\) be the number of conditional class regimes for generation, \(o_{j}\in\mathbb{R}^{J}\) be the onehot encoding vector for classes \(j=1,\ldots,J\), and let \(\theta_{E_{d}}\) and \(\theta_{E_{g}}\) be learnable parameters for embedding weight tensors \(E_{d},E_{g}\).  
Embedding weight tensors \(E_{d},E_{g}\) map onehot encodings \(o_{j}\) to class embedding vectors \(e_{d},e\in\mathbb{R}^{N_{d_{d}}},e_{g}\in\mathbb{R}^{N_{g}}\) as learnable class embeddings for the conditional discriminator and generator TCNs:  
\[E_{d}:\mathbb{R}^{J}\rightarrow\mathbb{R}^{N_{E_{d}}};E_{d}(o_{j};\theta_{E_ {d}})\mapsto e_{d} \tag{9}\]  
\[E_{g}:\mathbb{R}^{J}\rightarrow\mathbb{R}^{N_{E_{g}}};E_{g}(o_{j};\theta_{E_ {g}})\mapsto e_{g} \tag{10}\]  
\(cD\) and \(cG\) are conditional discriminator and generator networks defined as follows:  
\[cD:\mathbb{R}^{N_{X}\times T_{RFS(cD)}\times J}\rightarrow\mathbb{R};cD(X|C_ {j})=cD(X|o_{j},\theta_{E_{d}},\theta_{d})\mapsto[0,1] \tag{11}\]  
\[cG:\mathbb{R}^{N_{Z}\times T_{(RFS(cG)+RFS(cD)-1)}\times J}\rightarrow\mathbb{ R}^{N_{X}\times T_{RFS(cD)}\times J};cG(Z|C_{j})=cG(Z|o_{j},\theta_{E_{g}}, \theta_{g})\mapsto\hat{X}|C_{j} \tag{12}\]  
where \(N_{X},N_{Z}\) are the dimensions of the input data and noise prior distributions; the input data distribution is an \(N_{X}\)-variate time series of RFS length \(T_{RFS(cD)}\); the noise prior distribution is an \(N_{Z}\)-variate time series of RFS length \(T_{(RFS(cG)+RFS(cD)-1)}\); the receptive field sizes of the conditional discriminator and generator are \(T_{RFS(cD)}\) and \(T_{RFS(cG)}\).  
The required time dimension of the noise prior used as an input into \(cG\) is \(T_{(RFS(cG)+RFS(cD)-1)}\) so that the output of synthetic data \(\hat{X}|C_{j}\) is of time dimensionality \(T_{RFS(cD)}\) for discriminator evaluation.  
The aim is to determine conditional generator \(\theta_{g}\) and class embedding \(\theta_{E_{g}}\) parameters such that \(\mathbb{P}_{g}|C_{j}=\mathbb{P}_{r}|C_{j},\forall j=1,\ldots,J\), i.e., \(\hat{X}|C_{j}\sim\mathbb{P}_{g}|C_{j},X|C_{j}\sim\mathbb{P}_{r}|C_{j}\), and that  
\[cG\Big{(}Z|C_{j};p_{Z}(z),\theta_{E_{g}},\theta_{g}\Big{)}=p_{X|C_{j}}(x,o_{j })=\mathbb{P}_{r}|C_{j} \tag{13}\]  
Parameters for \(\theta_{g},\theta_{E_{g}}\) can be learned through an alternating optimisation of generator and discriminator loss functions:  
\[\min_{\theta_{g},\theta_{E_{g}}}\mathbb{E}_{j}\mathbb{E}\Big{[}\log\Big{(}1-D _{\theta_{g},\theta_{E_{d}}}\Big{(}G_{\theta_{g},\theta_{E_{g}}}(Z|C_{j}) \Big{)}\Big{)}\Big{]} \tag{14}\]  
\[\max_{\theta_{g}\theta_{E_{g}}}\mathbb{E}_{j}\mathbb{E}_{j}\Big{[}\log D_{ \theta_{g},\theta_{E_{g}}}(X|C_{j})\Big{)}+\mathbb{E}\Big{[}\log\Big{(}1-D_{ \theta_{g},\theta_{E_{d}}}\Big{(}G_{\theta_{g},\hat{\theta}_{E_{g}}}(Z|C_{j}) \Big{)}\Big{)}\Big{]} \tag{15}\]This is equivalent to optimising the _conditional_ vanilla GAN adversarial loss analogous to an _unconditional_ vanilla GAN ([PERSON] et al., 2016):  
\[\min_{\theta_{g}\theta_{Eg}}\max_{\theta_{Eg}}\mathbb{E}_{j}\mathbb{E}_{j} \mathbb{E}\Big{[}\log D_{\theta_{\tilde{d}}\theta_{Eg}}\big{(}X|\mathcal{C}_{j }\big{)}\Big{]}+\mathbb{E}_{j}\mathbb{E}\Big{[}\log\Big{(}1-D_{\theta_{\tilde{d }}\theta_{Eg}}\big{(}G_{\theta_{g}\theta_{Eg}}\big{(}Z|\mathcal{C}_{j}\big{)} \big{)}\Big{)}\Big{)}\Big{]} \tag{16}\]  
Expectations are estimated by sampling a minibatch of size \(M\in\mathbb{N}\) for all classes \(j\in j=1,\dots,J\).