# \[WSS20\] Text generation using GANs

**URL:** <https://community.wolfram.com/t/wss20-text-generation-using-gans/16346>\
**Category:** Staff Picks\
**Tags:** data-science, machine-learning, computational-linguistics, staff-pick, wolfram-summer-research-institute, neural-networks, artificial-intelligence\
**Created:** [July 14, 2020, 3:58pm UTC](https://community.wolfram.com/t/wss20-text-generation-using-gans/16346 "2020-07-14T15:58:48Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![sumansid1113](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/sumansid1113/32/19052_2.png) [@sumansid1113](https://community.wolfram.com/u/sumansid1113)\
**Post date:** [July 14, 2020, 3:58pm UTC](https://community.wolfram.com/t/wss20-text-generation-using-gans/16346/1 "2020-07-14T15:58:48Z")

</div>

![test.gif](https://global.discourse-cdn.com/wolfram/original/3X/6/7/674411ed47bee9a79156c5b77c6e388c3b097936.gif)

[Open in Wolfram Cloud ↗](https://www.wolframcloud.com/obj/6449bcc6-e868-444f-8980-c04ce59a1d59)

---

<div class="post-metadata">

**Author:** ![michaelsollami](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/michaelsollami/32/11302_2.png) [@michaelsollami](https://community.wolfram.com/u/michaelsollami)\
**Post date:** [July 17, 2020, 8:48pm UTC](https://community.wolfram.com/t/wss20-text-generation-using-gans/16346/2 "2020-07-17T20:48:11Z")

</div>

Nice project! I wanted to run your code, but there’s many missing definitions, e.g. convolutionBlock, ArrayLayer, vocabulary, some .wlnet files etc.) do you think you can add them so it is runnable?

---

<div class="post-metadata">

**Author:** ![sumansid1113](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/sumansid1113/32/19052_2.png) [@sumansid1113](https://community.wolfram.com/u/sumansid1113)\
**Post date:** [July 17, 2020, 10:40pm UTC](https://community.wolfram.com/t/wss20-text-generation-using-gans/16346/3 "2020-07-17T22:40:09Z")

</div>

Hi Mike,

Thank you for your interest in my project. I have uploaded .wlnet files here [GitHub - sumansid/Text-Generation-using-GANs: Using (Convolution based) Generative Adversarial Networks to generate text and comparing it with the Wolfram Character Level pretrained model. · GitHub](https://github.com/sumansid/Text-Generation-using-GANs) and will also add the full notebook. Please let me know if you have any questions.

---

<div class="post-metadata">

**Author:** ![sumansid1113](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/sumansid1113/32/19052_2.png) [@sumansid1113](https://community.wolfram.com/u/sumansid1113)\
**Post date:** [August 31, 2020, 1:47am UTC](https://community.wolfram.com/t/wss20-text-generation-using-gans/16346/4 "2020-08-31T01:47:28Z")

</div>

Full Notebook can be found here : [https://notebookarchive.org/2020-07-6hfo8lo](https://notebookarchive.org/2020-07-6hfo8lo)

---

<div class="post-metadata">

**Author:** ![wolframcommunity](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/wolframcommunity/32/8335_2.png) [@wolframcommunity](https://community.wolfram.com/u/wolframcommunity)\
**Post date:** [August 31, 2020, 1:52pm UTC](https://community.wolfram.com/t/wss20-text-generation-using-gans/16346/5 "2020-08-31T13:52:09Z")

</div>

![news-congrads-kkluyshnik-02-04-19.jpg](https://global.discourse-cdn.com/wolfram/original/3X/6/a/6a310c2d0904616faf4e6e148260c9f29ab9f4eb.jpeg) – you have earned _ **Featured Contributor Badge** _ ![2015-11-02_10-07-11.png](https://global.discourse-cdn.com/wolfram/original/3X/5/0/50e59c9ead62f729e7130d3ea1482555a75602b6.png)  
Your exceptional post has been selected for our editorial column _ **Staff Picks** _ [http://wolfr.am/StaffPicks](http://wolfr.am/StaffPicks) and [Your Profile](http://community.wolfram.com/web/sumansid1113) is now distinguished by a _ **Featured Contributor Badge** _ and is displayed on the [Featured Contributor Board](https://community.wolfram.com/people). Thank you!

---

<div class="post-metadata">

**Author:** ![sumansid1113](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/sumansid1113/32/19052_2.png) [@sumansid1113](https://community.wolfram.com/u/sumansid1113)\
**Post date:** [August 31, 2020, 5:11pm UTC](https://community.wolfram.com/t/wss20-text-generation-using-gans/16346/6 "2020-08-31T17:11:28Z")

</div>

Thank you so much !

---

<div class="post-metadata">

**Author:** ![pedrogcabral](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/pedrogcabral/32/34157_2.png) [@pedrogcabral](https://community.wolfram.com/u/pedrogcabral)\
**Post date:** [September 1, 2020, 3:52pm UTC](https://community.wolfram.com/t/wss20-text-generation-using-gans/16346/7 "2020-09-01T15:52:43Z")

</div>

Impressive! Really well written. I like the GIF!

---

<div class="post-metadata">

**Author:** ![sumansid1113](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/sumansid1113/32/19052_2.png) [@sumansid1113](https://community.wolfram.com/u/sumansid1113)\
**Post date:** [September 1, 2020, 3:57pm UTC](https://community.wolfram.com/t/wss20-text-generation-using-gans/16346/8 "2020-09-01T15:57:02Z")

</div>

Thanks Pedro ! I’m glad you liked the project 😃

---

<div class="post-metadata">

**Author:** ![stvincentwower](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/stvincentwower/32/13757_2.png) [@stvincentwower](https://community.wolfram.com/u/stvincentwower)\
**Post date:** [September 2, 2020, 3:03am UTC](https://community.wolfram.com/t/wss20-text-generation-using-gans/16346/9 "2020-09-02T03:03:01Z")

</div>

> GANs are very unstable during training as there are two networks that  
> are dependent on each other for improvements in their performance.  
> While several methods to improve the stability were implemented in the  
> GAN architecture, they still suffer from non-convergence. Due to their  
> unstable nature, an early stopping method fails to retrieve the best  
> performing GAN model. In order to solve this, we will save a  
> checkpoint of the model in every round along with the n-gram  
> performance metric to select the best performing model.

This stuck out to me as similar to my experience implementing a GAN in Tensorflow2. The instabilities were maddening. Still trying to improve some problems with mode collapse. Glad to hear your model selection strategy eventually worked.

---

<div class="post-metadata">

**Author:** ![stvincentwower](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/stvincentwower/32/13757_2.png) [@stvincentwower](https://community.wolfram.com/u/stvincentwower)\
**Post date:** [September 2, 2020, 3:03am UTC](https://community.wolfram.com/t/wss20-text-generation-using-gans/16346/10 "2020-09-02T03:03:03Z")

</div>

> GANs are very unstable during training as there are two networks that  
> are dependent on each other for improvements in their performance.  
> While several methods to improve the stability were implemented in the  
> GAN architecture, they still suffer from non-convergence. Due to their  
> unstable nature, an early stopping method fails to retrieve the best  
> performing GAN model. In order to solve this, we will save a  
> checkpoint of the model in every round along with the n-gram  
> performance metric to select the best performing model.

This stuck out to me as similar to my experience implementing a GAN in Tensorflow2. The instabilities were maddening. Still trying to improve some problems with mode collapse. Glad to hear your model selection strategy eventually worked.

---

<div class="post-metadata">

**Author:** ![sumansid1113](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/sumansid1113/32/19052_2.png) [@sumansid1113](https://community.wolfram.com/u/sumansid1113)\
**Post date:** [September 2, 2020, 8:37pm UTC](https://community.wolfram.com/t/wss20-text-generation-using-gans/16346/11 "2020-09-02T20:37:40Z")

</div>

Thank you. Good to hear that you had similar experience. Check out GAN Hacks by Soumith Chintala. [GitHub - soumith/ganhacks: starter from "How to Train a GAN?" at NIPS2016 · GitHub](https://github.com/soumith/ganhacks) .

---

<div class="post-metadata">

**Author:** ![osamasarhan](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/osamasarhan/32/27053_2.png) [@osamasarhan](https://community.wolfram.com/u/osamasarhan)\
**Post date:** [March 19, 2021, 5:22pm UTC](https://community.wolfram.com/t/wss20-text-generation-using-gans/16346/12 "2021-03-19T17:22:01Z")

</div>

Excellent work.

---

<div class="post-metadata">

**Author:** ![philonnguyen](https://avatars.discourse-cdn.com/v4/letter/p/e19adc/32.png) [@philonnguyen](https://community.wolfram.com/u/philonnguyen)\
**Post date:** [June 14, 2022, 10:21pm UTC](https://community.wolfram.com/t/wss20-text-generation-using-gans/16346/13 "2022-06-14T22:21:11Z")

</div>

Missing definitions such as ArrayLayer… Notebook does not work… Any ideas?
