**3. Transfer Learning Based on Conditional Variational Generative Adversarial Networks (TL-CVAE-GAN)**

In this paper, we proposed a model named transfer learning based conditional variational generative adversarial networks (TL-CVAE-GAN) for fault diagnosis of wind turbine transmission platform datasets under different conditions. An improved CVAE-GAN is used for transfer learning to achieve the generation of unknown samples in different conditions.

As shown in Table 1, the data in this paper include *XS*1, *XS*2, *XT*1, and *XT*2. *XS* is the source domain data and *XT* is the target domain data. *XS*<sup>1</sup> and *XT*<sup>1</sup> are in operating speed 1, *XS*<sup>2</sup> and *XT*<sup>2</sup> are in operating speed 2. In this paper, *XT*<sup>2</sup> is unknown.

**Table 1.** Variables and conditions of the data.


The model structure of TL-CVAE-GAN is shown in Figure 3. A generative model CVAE-GAN1 is trained to generate *XS*<sup>2</sup> from *XS*1, and another generative model CVAE-GAN2 is trained to generate *XT*<sup>2</sup> from *XT*1. The structure of the neural network model is

the same for CVAE-GAN1 and CVAE-GAN2, both containing: an encoder, E, a decoder, De, a generator, G, and a discriminator, D.

**Figure 3.** Model structure of TL-CVAE-GAN.

Assume that *X*<sup>1</sup> is the data corresponding to *Speed*<sup>1</sup> and *X*<sup>2</sup> is the data corresponding to *Speed*2. The data, *X*1, is fed into the encoder, E, together with *Speed*<sup>1</sup> for dimensionality reduction to obtain an intermediate code, *z*, with the *Speed*<sup>1</sup> information removed; *z* is input to the decoder, De, for reconstruction, and the mean, *u*, and variance, *σ*, are additionally obtained from *z.* The variance, *σ*, is multiplied by the random noise, *e*, plus the mean, *u*, to obtain *zs*; *zs* is fed into the generator, G, together with *Speed*<sup>2</sup> to produce *X*2 . The real *X*<sup>2</sup> is fed into the discriminator, D, together with the generated *X*2 for discrimination. The accuracy of the generated model is improved by confronting the generator with the discriminator.

The MMD of *XS*<sup>1</sup> to *XT*<sup>1</sup> is solved for domain adaptation. The MMD is added to the loss function of the generator CVAE-GAN2 for backpropagation to generate *XT*<sup>2</sup> .

The TL-CVAE-GAN model is divided into the following steps:

In the first step, update the parameters of CVAE-GAN1 and generate *XS*<sup>2</sup> . The source data *XS*<sup>1</sup> and its corresponding rotational speed are input into encoder E to obtain the intermediate key feature, *z*, with the rotational speed information removed. The mean value, *u*, and variance, *σ*, are obtained from *z*, then a new sample, *zs*, is formed by *u*, *σ*, and the noise *e*; *z* is fed into the decoder De for reconstruction and *zs* and the corresponding speed, *speed*2, are input to the generator, G, to generate *XS*<sup>2</sup> . The discriminator, D, discriminates between the generated data, *XS*<sup>2</sup> , and the real data, *XS*2. The loss of CVAE-GAN1 is:

$$Loss\_1 = Loss\_{VAE} + Loss\_{GAN} \tag{9}$$

$$Loss\_{VAE} = \left\| X\_{\rm S1} - X\_{\rm S1}{'} \right\|\_{2}^{2} + \frac{1}{2} (-\log \sigma^{2} + \mu^{2} + \sigma^{2} - 1) \tag{10}$$

$$Loss\_{GAN} = -E\_{x \sim p\_\mathbb{P}} \left[ \log D(X\_{S2}) \right] - E\_{z \sim p\_\mathbb{Z}} \left[ \log \left( 1 - D(G(z\_s, speed\_2)) \right) \right] \tag{11}$$

where *XS*<sup>1</sup> is the input source data, *XS*<sup>1</sup> is the generated data from *XS*1, *μ* and *σ* are the mean and covariance of the output of the potential vector from the encoder network, E, *XS*<sup>2</sup> is another input source data that the operating conditions are different from *XS*1, *speed*<sup>2</sup> is the operating speed of *XS*2, and *zs* is the potential vector of source data from encoder network, E.

In the second step, update the parameters of CVAE-GAN2. The MMD between CVAE-GAN1 and CVAE-GAN2 is calculated. The MMD is added to the loss of CVAE-GAN2 to achieve the generator's domain migration. The loss is as follows:

$$Loss\_2 = MMD(X\_{\ $1}, X\_{\$ 1}) + MMD(z\_{\ $}, z\_{\$ }) + MMD(X\_{\ $2}, X\_{\$ 2}) + MMD(f\_D(X\_{\ $2}), f\_D(X\_{\$ 2})) \tag{12}$$

where *fD'*(*x*) denotes the features in the penultimate layer of the discriminator, D. *XT*<sup>1</sup> and *XT*<sup>2</sup> are the target data and *zs* and *zt* are the potential vector of source data and target data from encoder network E.

In the last step, repeat steps 1 and steps 2 for 5 training cycles to generate the unknown data, *XT*<sup>2</sup> .

The model structure of the classifier is shown in Figure 4. The existing data, *XS*1, *XS*2, *XT*1, and the generated data, *XT*<sup>2</sup> , are together input into the classifier for training.

**Figure 4.** Model structure of the classifier.

The classifier model contains three convolution layers, three BatchNorm1d, three MaxPool1d, and one fully-connected layer. The number of neurons in each layer is shown in Figure 4. The activation function for the last layer is Softmax and the activation functions for the other layers are Relu. All the data goes through the fast Fourier transform, and is then fed into the model. The classifier is updated by:

$$Loss\_{21} = \sum\_{x\_i, y\_i \sim T\_i} \left[ y\_i \log y\_i^{'} + (1 - y\_i) \log(1 - y\_i^{'}) \right] \tag{13}$$

where *yi* is the real label of the data and *yi*' is the output of the classifier model.

The feature embedding is visualized by t-SNE to test the effectiveness of the proposed model. The complete algorithm flow is shown in Algorithm 1.

**Algorithm 1.** TL-CVAE-GAN

**Input:** Input training data, *Tr* = {(*XS*1,*YS*1),(*XS*2,*YS*2),(*XT*1,*YT*1)}, testing data, *Te*, classified model, *fC*. In the CVAE-GAN1 model: encoder network, *fE*1, decoder network, *fDE*1, generator network, *fG*1, and discriminator network, *fD*1. In the CVAE-GAN2 model: encoder network, *fE*2, generator network, *fG*2, discriminator network, *fD*2.The learning rate, *lr*. ########################Cycle 5 times #################### 1: For f from 0 to 4: ########################train CVAE-GAN1 model #################### 2: For each training epoch, do: 3: For each batch, do: 4: *zi* = *fE*1(*xs*1*i, Speed*1), *xs*1*i*' = *fDE*1(*zi*), the mean value, *usi*, and variance, *σsi*, are obtained from *zi*, sample *e* from the random noise *S*. *zsi* = *usi* +*σsi* \**e*, *xs*2*i*'= *fG*1(*zsi, Speed*2), *ds*2*i*'= *fD*1(*xs*2*i*'), *ds*2*i*= *fD*1(*xs*2*i*) 5: Backward propagation by Equation (9). 6: end 7: save CVAE-GAN1 model #################### train CVAE-GAN2 model use MMD ####################### 8: download CVAE-GAN1 model. Use the parameters of the CVAE-GAN1 model as the initial parameters of CVAE-GAN2. 9: For each training, do: 10: For each batch, do: 11: *zi* = *fE2*(*xt*1*i*), *zti* = *uti* +*σti* \**e*, *xt*2*i*'= *fG*2(*zti*), 12: Backward propagation by Equation (12). 13: end 14: save CVAE-GAN2 model 15: *lr* = *lr*/2 16: if *f* > 0: 17: download the CVAE-GAN2 model. Use the parameters of the CVAE-GAN2 model as the initial parameters of CVAE-GAN1. 18: end ########### train classifier net use *Tr* and the generate data *XT*<sup>2</sup> ################# ########the input data is X = {(*XS*1, *YS*1), (*XS*2, *YS*2), (*XT*1, *YT*1), (*XT*<sup>2</sup> , *YT*2)}########### 19: For each training, do: 20: For each batch, do: 21: *yi*' = *fC*(*xi*) 22: Backward propagation by Equation (13). 23: end ###################### testing results and t-SNE ######################### 24: For the test set, calculate *cTi* = *fC* (*Tei*), calculate the accuracy, and draw the t-SNE diagram. **Output:** testing results.
