## 5 Methodologies
### Models
#### 5.1.5 RSQGAN Training Procedure
```
Inputs:Real data \(X\in\mathbb{R}^{N_{X}\times T}\), \(J\) conditional class regimes \(\{\mathcal{C}_{j}\}_{j=1}^{J}\), onehot encodings \(\{o_{j}\}\), regimes \(\{\mathcal{X}^{C_{j}}\}_{j=1}^{J}\), \(\mathcal{X}^{C_{j}}\in\mathbb{R}^{N_{X}\times(\tau_{j}-\tau_{j-1}+1)}\) minibatch size \(M\in\mathbb{N}\), max epochs \(E\in\mathbb{N}\) TCN hyperparameters: # of temporal blocks \(L\), inner blocks per temporal block \(B\), kernel size \(K\), dilation factor \(D\), skip layer \(\dim\)\(N_{skip}\), temporal block dims \(\mathfrak{L}=\{N_{1},\ldots,N_{L}\}\), inner block dims \(\mathfrak{B}=\{N_{l_{i}}\}_{i=1}^{B},\forall l=\{1,\ldots,L\}\) Topology:Conditional Discrimator TCN: \(cD(X|\mathcal{C}_{j}\in\mathbb{R}^{N_{X}\times T_{RS(D)}\times J};\theta_{d}, \theta_{E_{d}},\mathfrak{L},\mathfrak{B},N_{skip},K,D,\phi)\mapsto[0,1]\) Conditional Generator TCN: \(cG(Z|\mathcal{C}_{j}\in\mathbb{R}^{N_{Z}\times(T_{RS(D)}+T_{RS(G)}-1)\times J };\theta_{g},\theta_{E_{g}},\mathfrak{L},\mathfrak{B},N_{skip},K,D,\phi)) \mapsto\mathbb{R}^{N_{X}\times T_{RS(D)}}\) \(cD\) learning rate \(\alpha_{d}\), \(cG\) learning rate \(\alpha_{g}\) Outputs:Optimal TCN parameters: \(\theta_{g}^{*},\theta_{d}^{*}\) Class embedding parameters: \(\theta_{E_{g}},\theta_{E_{d}}\) Conditional Synthetic Data: \(\{\tilde{X}|\mathcal{C}_{j}\}_{j=1}^{J}\), \(\tilde{X}|\mathcal{C}_{j}\in\mathbb{R}^{N_{X}\times(\tau_{j}-\tau_{j-1}+1)}\) init params \(\theta_{g},\theta_{d},\theta_{E_{g}},\theta_{E_{d}}\) given topology \(L,B,K,D,N_{skip},\mathfrak{L},\mathfrak{B}\) for\(e=1\) to \(E\)do \(\{X_{i}|\mathcal{C}_{j}\}_{i=1}^{M},\forall j\in\{1,\ldots,J\}\) /* sample real minibatches \(M\), \(\forall j\) */ \(\{Z_{i}\}_{i=1}^{M}\) /* draw minibatch of noise prior */ Simulate \(\{\tilde{X}_{i}|\mathcal{C}_{j}\}_{i=1}^{M},\forall j\in\{1,\ldots,J\};\tilde{X }_{i}|\mathcal{C}_{j}=cG(Z,o_{j};\hat{\theta}_{g},\hat{\theta}_{E_{g}})\) // stop if properties of \(X\) or \(cG\), \(cD\) loss conditions met ifstoping condition(s) met:then break else // Train generator: Estimate \(\mathtt{G}\) minibatch gradient \(\Delta_{\theta_{g}}\leftarrow\
abla_{\theta_{g}}\frac{1}{J}\sum_{j=1}^{J} \left[\frac{1}{M}\sum_{i=1}^{M}\log\left(1-cD_{\hat{\theta}_{d}\hat{\theta}_{ E_{d}}}\left(G_{\theta_{g}\hat{\theta}_{E_{g}}}\left(Z_{i}|\mathcal{C}_{j} \right)\right)\right)\right]\) \(\Delta_{\theta_{E_{g}}}\leftarrow\
abla_{\theta_{E_{g}}}\frac{1}{J}\sum_{j=1}^ {J}\left[\frac{1}{M}\sum_{i=1}^{M}\log\left(1-cD_{\hat{\theta}_{d}\hat{\theta }_{E_{g}}}\left(G_{\theta_{g}\hat{\theta}_{E_{g}}}\left(Z_{i}|\mathcal{C}_{j} \right)\right)\right)\right]\) // Descond generator and embedding tensor gradient \(\theta_{g}\leftarrow\theta_{g}-\alpha_{g}\cdot\Delta_{\theta_{g}},\theta_{E_{g }}\leftarrow\theta_{E_{g}}-\alpha_{g}\cdot\Delta_{\theta_{E_{g}}}\) // Train discriminator: Estimate \(\mathtt{D}\) minibatch gradient \(\Delta_{\theta_{d}}\leftarrow\
abla_{\theta_{d}}\frac{1}{J}\sum_{j=1}^{J} \left[\frac{1}{M}\sum_{i=1}^{M}\log D_{\theta_{d}\theta_{E_{g}}}\left(X_{i}| \mathcal{C}_{j}\right)+\log\left(1-D_{\theta_{d}\theta_{E_{g}}}\left(\tilde{X }_{i}|\mathcal{C}_{j}\right)\right)\right]\) \(\Delta_{\theta_{E_{d}}}\leftarrow\
abla_{\theta_{E_{g}}}\frac{1}{J}\sum_{j=1}^ {J}\left[\frac{1}{M}\sum_{i=1}^{M}\log D_{\theta_{d}\theta_{E_{g}}}\left(X_{i} |\mathcal{C}_{j}\right)+\log\left(1-D_{\theta_{d}\theta_{E_{g}}}\left(\tilde{X }_{i}|\mathcal{C}_{j}\right)\right)\right]\) // ascend discriminator and embedding tensor gradient \(\theta_{d}\leftarrow\theta_{d}+\alpha_{d}\cdot\Delta_{\theta_{d}},\theta_{E_{d }}\leftarrow\theta_{E_{d}}+\alpha_{d}\cdot\Delta_{\theta_{E_{d}}}\) // Generate synthetic paths \(\tilde{X}|\mathcal{C}_{j}=cG_{\theta_{g}^{*}\hat{\theta}_{E_{g}}}\left(Z,o_{j} \right),\forall j\in\{j=1,\ldots,J\}\) return\(\theta_{g}^{*},\theta_{E_{g}}^{*},\theta_{d}^{*},\theta_{E_{d}^{*}}^{*},\{\tilde{X}| \mathcal{C}_{j}\}_{j=1}^{J}\)
```  
**Algorithm 1**RSQGAN training