{
  "id": 187653,
  "title": "Extracting insights on CycleGANs from papers.",
  "url": "/competitions/gan-getting-started/discussion/187653",
  "author_name": "Sarthak khandelwal",
  "post_date": "2020-09-29T18:58:38.707000",
  "votes": 4,
  "comment_count": 0,
  "views": 0,
  "content": "<p>This is my first time working on GANs. At first I was very confused where to start and what to do to get a better grasp over GANs.</p>\n<p>I Finally came up with the following path:-</p>\n<ol>\n<li>Get an high overview of what GANs are and their scope.</li>\n<li>Go through the research papers associated with it. The research papers I've gone through were <a href=\"https://arxiv.org/pdf/1511.06434.pdf\" target=\"_blank\">Deep Convolutional Generative Adversarial Networks</a>, <a href=\"https://arxiv.org/pdf/1611.07004.pdf\" target=\"_blank\">Image to Image Translation with Conditional Adversarial Networks</a> and <a href=\"https://arxiv.org/abs/1703.10593\" target=\"_blank\">Unpaired Image to Image Translation using Cycle-Consistent Adversarial Networks</a>.</li>\n<li>Going through the notebooks hosted in this competition to understand how specifically to employ the power of GANs for this particular scenario. I've gone through <a href=\"https://www.kaggle.com/amyjang/monet-cyclegan-tutorial\" target=\"_blank\">Amy Jang's tutorial</a> currently and have a good understanding of what and how exactly to do in this particular competition.</li>\n</ol>\n<p>In this post apart from sharing my progress till now, I would also like to share the insights that I gained when going through the research papers. Explaining about all of them could make this post a little longer and thus I would only be explaining about the paper corresponding to <strong>Cyclic GANs</strong>.</p>\n<p>Let us first gather a glossary of terms that we would be using further in this post.</p>\n<ol>\n<li>GAN: GAN or Generative Adversarial Networks are the networks with at least two models (more than two in cases like Cyclic GANs). One model is called as <strong>Generator model</strong> and the other one is called as <strong>Discriminator model</strong>. The Generator model learns to generate real world like images with the help of the Discriminator model which tries its best to distinguish an image as fake or real. Both the model tries their best on respective tasks and the ideal condition is when the Discriminator is unable to classify an image as fake.</li>\n<li>Adversarial Loss: The loss associated with the Discriminator.</li>\n<li>Cyclic Consistency Loss: Loss calculated to make generator networks consistent to each other.</li>\n</ol>\n<p>Let's Now try to get some main insights from the paper-</p>\n<p>Normally we train the Generator model to learn a mapping or relationship b/w image in set X to image in set Y.  This approach is pretty much fine when we have <strong>paired training data</strong> or a predefined relationship b/w images in set X and set Y. But in case of <strong>unpaired images</strong> or when there is no relationship b/w images in set X and set Y, we need to come up with some advanced implementations. Such an implementation is <strong>Cyclic GAN</strong>. It is an improved version of GAN which makes use of <strong>adversarial loss</strong> along with <strong>cyclic-consistency loss</strong> to determine a correct relationship b/w images in set X and set Y.</p>\n<p>So, a Cyclic GAN consists of two Generator models and two Discriminator models.<br>\nOne generator (G) tries to learn a mapping from images in set X to set Y and the other generator (F) does the opposite of learning a mapping from images in set Y to set X. <code>G</code> and <code>F</code> should be inverse of each other.</p>\n<p>One Discriminator model (D_X) learns to classify the real and fake images in set X and the other Discriminator (D_Y) learns to classify the real and fake images in set Y. </p>\n<p>We calculate losses for both of these discriminators and generators. However there are still chances of our model being wrongly trained. One of the possible cases could be that images from set X would  map to some random images in set Y which misleads the model in learning well. Hence we include another loss function called as <strong>cyclic consistency loss</strong> to constantly keep a check of the reverse translation.<br>\nFor example consider an image <code>x</code> in set X and another image <code>y</code> in set Y. We learn a mapping from <code>x</code> to <code>y</code> such that G(x) is similar to y. Now with the help of cyclic loss, we also make sure that F(G(x)) would give us an image similar to <code>x</code>.  That means   <code>x-&gt;G(x)-&gt;F(G(x))-&gt;x</code> should hold.<br>\nDisobeying the above rule would increase the loss of the model and ultimately tries to improve its performance.</p>\n<p>Now the final objective function would be a sum of adversarial losses and cyclic consistency loss. The cyclic consistency loss is multiplied by a hyperparameter named <code>lambda</code> which controls the relative importance of the two objectives.</p>\n<p>So, this is all for knowing about Cyclic GANs on a high level. You can now go for reading out the research paper if interested or just simply continue making contributions to this competition.</p>\n<p>~Happy Coding~</p>",
  "messages": [
    {
      "id": 1031895,
      "postDate": "2020-09-29T18:58:38.707Z",
      "content": "<p>This is my first time working on GANs. At first I was very confused where to start and what to do to get a better grasp over GANs.</p>\n<p>I Finally came up with the following path:-</p>\n<ol>\n<li>Get an high overview of what GANs are and their scope.</li>\n<li>Go through the research papers associated with it. The research papers I've gone through were <a href=\"https://arxiv.org/pdf/1511.06434.pdf\" target=\"_blank\">Deep Convolutional Generative Adversarial Networks</a>, <a href=\"https://arxiv.org/pdf/1611.07004.pdf\" target=\"_blank\">Image to Image Translation with Conditional Adversarial Networks</a> and <a href=\"https://arxiv.org/abs/1703.10593\" target=\"_blank\">Unpaired Image to Image Translation using Cycle-Consistent Adversarial Networks</a>.</li>\n<li>Going through the notebooks hosted in this competition to understand how specifically to employ the power of GANs for this particular scenario. I've gone through <a href=\"https://www.kaggle.com/amyjang/monet-cyclegan-tutorial\" target=\"_blank\">Amy Jang's tutorial</a> currently and have a good understanding of what and how exactly to do in this particular competition.</li>\n</ol>\n<p>In this post apart from sharing my progress till now, I would also like to share the insights that I gained when going through the research papers. Explaining about all of them could make this post a little longer and thus I would only be explaining about the paper corresponding to <strong>Cyclic GANs</strong>.</p>\n<p>Let us first gather a glossary of terms that we would be using further in this post.</p>\n<ol>\n<li>GAN: GAN or Generative Adversarial Networks are the networks with at least two models (more than two in cases like Cyclic GANs). One model is called as <strong>Generator model</strong> and the other one is called as <strong>Discriminator model</strong>. The Generator model learns to generate real world like images with the help of the Discriminator model which tries its best to distinguish an image as fake or real. Both the model tries their best on respective tasks and the ideal condition is when the Discriminator is unable to classify an image as fake.</li>\n<li>Adversarial Loss: The loss associated with the Discriminator.</li>\n<li>Cyclic Consistency Loss: Loss calculated to make generator networks consistent to each other.</li>\n</ol>\n<p>Let's Now try to get some main insights from the paper-</p>\n<p>Normally we train the Generator model to learn a mapping or relationship b/w image in set X to image in set Y.  This approach is pretty much fine when we have <strong>paired training data</strong> or a predefined relationship b/w images in set X and set Y. But in case of <strong>unpaired images</strong> or when there is no relationship b/w images in set X and set Y, we need to come up with some advanced implementations. Such an implementation is <strong>Cyclic GAN</strong>. It is an improved version of GAN which makes use of <strong>adversarial loss</strong> along with <strong>cyclic-consistency loss</strong> to determine a correct relationship b/w images in set X and set Y.</p>\n<p>So, a Cyclic GAN consists of two Generator models and two Discriminator models.<br>\nOne generator (G) tries to learn a mapping from images in set X to set Y and the other generator (F) does the opposite of learning a mapping from images in set Y to set X. <code>G</code> and <code>F</code> should be inverse of each other.</p>\n<p>One Discriminator model (D_X) learns to classify the real and fake images in set X and the other Discriminator (D_Y) learns to classify the real and fake images in set Y. </p>\n<p>We calculate losses for both of these discriminators and generators. However there are still chances of our model being wrongly trained. One of the possible cases could be that images from set X would  map to some random images in set Y which misleads the model in learning well. Hence we include another loss function called as <strong>cyclic consistency loss</strong> to constantly keep a check of the reverse translation.<br>\nFor example consider an image <code>x</code> in set X and another image <code>y</code> in set Y. We learn a mapping from <code>x</code> to <code>y</code> such that G(x) is similar to y. Now with the help of cyclic loss, we also make sure that F(G(x)) would give us an image similar to <code>x</code>.  That means   <code>x-&gt;G(x)-&gt;F(G(x))-&gt;x</code> should hold.<br>\nDisobeying the above rule would increase the loss of the model and ultimately tries to improve its performance.</p>\n<p>Now the final objective function would be a sum of adversarial losses and cyclic consistency loss. The cyclic consistency loss is multiplied by a hyperparameter named <code>lambda</code> which controls the relative importance of the two objectives.</p>\n<p>So, this is all for knowing about Cyclic GANs on a high level. You can now go for reading out the research paper if interested or just simply continue making contributions to this competition.</p>\n<p>~Happy Coding~</p>",
      "rawMarkdown": "This is my first time working on GANs. At first I was very confused where to start and what to do to get a better grasp over GANs.\n\nI Finally came up with the following path:-\n1. Get an high overview of what GANs are and their scope.\n2. Go through the research papers associated with it. The research papers I've gone through were [Deep Convolutional Generative Adversarial Networks](https://arxiv.org/pdf/1511.06434.pdf), [Image to Image Translation with Conditional Adversarial Networks](https://arxiv.org/pdf/1611.07004.pdf) and [Unpaired Image to Image Translation using Cycle-Consistent Adversarial Networks](https://arxiv.org/abs/1703.10593).\n3. Going through the notebooks hosted in this competition to understand how specifically to employ the power of GANs for this particular scenario. I've gone through [Amy Jang's tutorial](https://www.kaggle.com/amyjang/monet-cyclegan-tutorial) currently and have a good understanding of what and how exactly to do in this particular competition.\n\nIn this post apart from sharing my progress till now, I would also like to share the insights that I gained when going through the research papers. Explaining about all of them could make this post a little longer and thus I would only be explaining about the paper corresponding to **Cyclic GANs**.\n\nLet us first gather a glossary of terms that we would be using further in this post.\n1. GAN: GAN or Generative Adversarial Networks are the networks with at least two models (more than two in cases like Cyclic GANs). One model is called as **Generator model** and the other one is called as **Discriminator model**. The Generator model learns to generate real world like images with the help of the Discriminator model which tries its best to distinguish an image as fake or real. Both the model tries their best on respective tasks and the ideal condition is when the Discriminator is unable to classify an image as fake.\n2. Adversarial Loss: The loss associated with the Discriminator.\n3. Cyclic Consistency Loss: Loss calculated to make generator networks consistent to each other.\n\nLet's Now try to get some main insights from the paper-\n\nNormally we train the Generator model to learn a mapping or relationship b/w image in set X to image in set Y.  This approach is pretty much fine when we have **paired training data** or a predefined relationship b/w images in set X and set Y. But in case of **unpaired images** or when there is no relationship b/w images in set X and set Y, we need to come up with some advanced implementations. Such an implementation is **Cyclic GAN**. It is an improved version of GAN which makes use of **adversarial loss** along with **cyclic-consistency loss** to determine a correct relationship b/w images in set X and set Y.\n\nSo, a Cyclic GAN consists of two Generator models and two Discriminator models.\nOne generator (G) tries to learn a mapping from images in set X to set Y and the other generator (F) does the opposite of learning a mapping from images in set Y to set X. `G` and `F` should be inverse of each other.\n\nOne Discriminator model (D_X) learns to classify the real and fake images in set X and the other Discriminator (D_Y) learns to classify the real and fake images in set Y. \n\nWe calculate losses for both of these discriminators and generators. However there are still chances of our model being wrongly trained. One of the possible cases could be that images from set X would  map to some random images in set Y which misleads the model in learning well. Hence we include another loss function called as **cyclic consistency loss** to constantly keep a check of the reverse translation.\nFor example consider an image `x` in set X and another image `y` in set Y. We learn a mapping from `x` to `y` such that G(x) is similar to y. Now with the help of cyclic loss, we also make sure that F(G(x)) would give us an image similar to `x`.  That means   `x->G(x)->F(G(x))->x` should hold.\nDisobeying the above rule would increase the loss of the model and ultimately tries to improve its performance.\n\nNow the final objective function would be a sum of adversarial losses and cyclic consistency loss. The cyclic consistency loss is multiplied by a hyperparameter named `lambda` which controls the relative importance of the two objectives.\n\nSo, this is all for knowing about Cyclic GANs on a high level. You can now go for reading out the research paper if interested or just simply continue making contributions to this competition.\n\n~Happy Coding~",
      "votes": 4
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "1031895": "This is my first time working on GANs. At first I was very confused where to start and what to do to get a better grasp over GANs.\n\nI Finally came up with the following path:-\n1. Get an high overview of what GANs are and their scope.\n2. Go through the research papers associated with it. The research papers I've gone through were [Deep Convolutional Generative Adversarial Networks](https://arxiv.org/pdf/1511.06434.pdf), [Image to Image Translation with Conditional Adversarial Networks](https://arxiv.org/pdf/1611.07004.pdf) and [Unpaired Image to Image Translation using Cycle-Consistent Adversarial Networks](https://arxiv.org/abs/1703.10593).\n3. Going through the notebooks hosted in this competition to understand how specifically to employ the power of GANs for this particular scenario. I've gone through [Amy Jang's tutorial](https://www.kaggle.com/amyjang/monet-cyclegan-tutorial) currently and have a good understanding of what and how exactly to do in this particular competition.\n\nIn this post apart from sharing my progress till now, I would also like to share the insights that I gained when going through the research papers. Explaining about all of them could make this post a little longer and thus I would only be explaining about the paper corresponding to **Cyclic GANs**.\n\nLet us first gather a glossary of terms that we would be using further in this post.\n1. GAN: GAN or Generative Adversarial Networks are the networks with at least two models (more than two in cases like Cyclic GANs). One model is called as **Generator model** and the other one is called as **Discriminator model**. The Generator model learns to generate real world like images with the help of the Discriminator model which tries its best to distinguish an image as fake or real. Both the model tries their best on respective tasks and the ideal condition is when the Discriminator is unable to classify an image as fake.\n2. Adversarial Loss: The loss associated with the Discriminator.\n3. Cyclic Consistency Loss: Loss calculated to make generator networks consistent to each other.\n\nLet's Now try to get some main insights from the paper-\n\nNormally we train the Generator model to learn a mapping or relationship b/w image in set X to image in set Y.  This approach is pretty much fine when we have **paired training data** or a predefined relationship b/w images in set X and set Y. But in case of **unpaired images** or when there is no relationship b/w images in set X and set Y, we need to come up with some advanced implementations. Such an implementation is **Cyclic GAN**. It is an improved version of GAN which makes use of **adversarial loss** along with **cyclic-consistency loss** to determine a correct relationship b/w images in set X and set Y.\n\nSo, a Cyclic GAN consists of two Generator models and two Discriminator models.\nOne generator (G) tries to learn a mapping from images in set X to set Y and the other generator (F) does the opposite of learning a mapping from images in set Y to set X. `G` and `F` should be inverse of each other.\n\nOne Discriminator model (D_X) learns to classify the real and fake images in set X and the other Discriminator (D_Y) learns to classify the real and fake images in set Y. \n\nWe calculate losses for both of these discriminators and generators. However there are still chances of our model being wrongly trained. One of the possible cases could be that images from set X would  map to some random images in set Y which misleads the model in learning well. Hence we include another loss function called as **cyclic consistency loss** to constantly keep a check of the reverse translation.\nFor example consider an image `x` in set X and another image `y` in set Y. We learn a mapping from `x` to `y` such that G(x) is similar to y. Now with the help of cyclic loss, we also make sure that F(G(x)) would give us an image similar to `x`.  That means   `x->G(x)->F(G(x))->x` should hold.\nDisobeying the above rule would increase the loss of the model and ultimately tries to improve its performance.\n\nNow the final objective function would be a sum of adversarial losses and cyclic consistency loss. The cyclic consistency loss is multiplied by a hyperparameter named `lambda` which controls the relative importance of the two objectives.\n\nSo, this is all for knowing about Cyclic GANs on a high level. You can now go for reading out the research paper if interested or just simply continue making contributions to this competition.\n\n~Happy Coding~"
  }
}