Giter Site home page Giter Site logo

lstm-generative-and-discriminative's Introduction

LSTM-Generative-and-Discriminative

Using LSTM neural network model for accurate text generation.

In this project, I create 2 LSTM networks: A generative network and a discriminative one. The generative network simply creates text. The discriminative network is trained to tell the difference between the generated text and human-written text. The hope is that the generative network can be trained to maximize the probability that the discriminative network thinks its generated text is human.

This is similar to the generative adversarial network (GAN) developed by Goodfellow et al, 2014.

Code for creating and training LSTM's is in LSTM.py and LSTM_layer.py. Testing code is in testing.py. The generator and discriminator are located in generator.py and discriminator.py. The two are combined in gan.py.

I attempted to get the GAN to memorize (overfit) words from the animals.txt file.

Results: The discriminator was able to classify words with 100% accuracy almost every time it was trained. The generator would manage to reduce its accuracy, but when the discriminator was trained again, it went back to 100%. My hope was that the generator would learn to copy words from the dataset so that the discriminator would have no way to tell the difference. Although the generator sometimes displayed words that almost looked like words from the dataset, they never stayed for long. The generator's words changed too much and didn't seem to change in a consistent manner. For example, the generator almost spelled out the word "orangutan" (it spelled "oranguaa"), but the letters quickly descended into gibberish again after a few more epochs.

So far, this program only uses numpy, not theano or tensorflow.

If you want to run the GAN, run the file testing.py. Currently, it displays 3 things on the console each iteration: the accuracy of the discriminator before training the generator, the accuracy of the discriminator after the generator learns to trick it, and 3 example words the generator made.

lstm-generative-and-discriminative's People

Contributors

mattweidman avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.