# Research on Wickerwork Patterns Creative Design and Development Based on Style Transfer Technology
## 3 Methods
### Algorithm Structure  
The goal of CycleGAN is to train the mapping function between two domains \(X\) and \(Y\). The model includes two generators \(G\):\(X\)\(\rightarrow\)\(Y\) and \(F\):\(Y\)\(\rightarrow\)\(X\), and two adversarial discriminators \(D_{X}\) and \(D_{Y}\). \(D_{X}\) is used to distinguish the image set \(\{x\}\) from the transformed image set \(\{F(y)\}\), and similarly, \(D_{Y}\) is used to distinguish the image set \(\{y\}\) from the transformed image set \(\{G(x)\}\). The network differs from GAN in that there are no longer separate generators \(G\) and discriminators \(D\), but two \(G\) and two \(D\). The generation of mapping relationships between two images can be accomplished by two \(G\) and two \(D\). Setting two generators and discriminators can avoid a style field of images are mapped to one image and ensure the effect of the generated images. The network introduces a cyclic loss function, which can keep the consistent of the cycle training process, and the specific implementation step is shown in Figure 4.  
In the recurrent consistency adversarial network, the generator \(G\) represents the mapping relationship from image \(X\) to image \(Y\), while the generator F represents the mapping relationship from image \(Y\) to image \(X\). The \(X\) image can produce images more like the \(Y\) style through the mapping relationship, and in turn the \(Y\) style images can also produce images from the \(X\) style domain through their mapping relationship, and the discriminator \(D_{X}\) to determine the authenticity of images from the \(X\) style domain The discriminator \(D_{y}\) is used to determine the authenticity of the images from the \(Y\) style domain. Adversarial Loss  
CycleGAN could apply adversarial losses to both mapping functions. For the mapping function \(G:X\)\(\rightarrow\)\(Y\) and its discriminator \(D_{Y}\), the objective function is expressed as [25]:  
\[ \begin{array}{ll}\mathcal{L}_{\text{GAN}}(G,D_{Y},X,Y)&=\mathbb{E}_{y\sim P_ {\text{data }}(y)}[\log D_{Y}(y)]\\ &+\mathbb{E}_{x\sim P_{data}}(x)[\log(1-D_{Y}(G(x)))]\end{array}  \tag{4}\]  
\(D_{Y}\) aims to discriminate the transformed sample \(G(x)\) from the true sample \(y\). \(G\) tries to generate \(G(x)\) similar to the image in the domain \(Y\). \(G\) aims to minimize the objective function, while \(D_{Y}\) aims to maximize the objective function, i.e., \(\min_{G}\)max \({}_{DY}L_{GAN}(G,D_{Y},X,Y)\). Similarly, the same adversarial loss function is used for the mapping function \(F\):\(Y\)\(\rightarrow\)\(X\) and its discriminator \(D_{X}\) as well is expressed as: \(\min_{F}\)max \({}_{DX}\)\(L_{GAN}(F,D_{X},Y,X)\). Cycle Consistency Loss  
In fact, the adversarial loss can train mappings \(G\) and \(F\) that produce outputs with the same distributions as the target domains \(Y\) and \(X\), respectively. However, if the network is trained well enough, it can map the same input image to any random image in the target domain, where any trained mapping can make the output distribution match the target distribution, and the output image matches the target domain well, but does not necessarily correspond to the input image. Therefore, only adversarial loss is no guarantee that the learned function can map a single input \(x_{i}\) to a desired output \(y_{i}\). Therefore, CycleGAN indicates that the trained mapping function should have cyclic consistency: for each image \(x\) in the \(X\) domain, the cyclic transformation of the image should convert \(x\) back to the original image, i.e., \(x\to G(x)\to F(G(x))\approx x\). This cycle is called forward cyclic consistency. Similarly, for each image \(y\) in the \(Y\) domain, \(G\) and \(F\) should satisfy the reverse cyclic consistency: \(y\to F(y)\to G(F(y))\approx y\). To achieve this, the loss function in CycleGAN is defined as [25]:  
\[ \begin{array}{ll}L_{cyc}(G,F)&=E_{x}\sim\text{Pdata}(x)[\left\|F(G(x))-x \right\|_{1}]\\ &+E_{y}\sim\text{Pdata}(y)[\left\|G(F(y))-y\right\|_{1}]\end{array}  \tag{5}\]  
The full objective is:  
\[