Git Product home page Git Product logo

simplernn's Introduction

simpleRNN

Example RNN for text generation from "Deep Learning With Keras" by Gulli and Pal (Chapter 6).

  • This repo is meant to be an ad hoc exploratory script for training a character-generating recurrent neural network using an example text from Project Gutenberg. It's not meant to provide state of the art performance or any insight into nuanced optimization of this sort of model for a real production use case. Just an overview of the basic idea.

  • Use the provided environment.yml file to create your own complete Python 3.6 environment with conda, including the specific dependencies needed for this example. E.g. conda env create -f environment.yml and source activate py36-keras-simpleRNN.

  • Read through some comments in the code for ways to experiment with changing the network and reference the source materials in the book "Deep Learning With Keras" by Gulli and Pal (Chapter 6).

Here is an example of the output you will see by executing the script simple_rnn.py:

Iteration #: 5
Epoch 1/1
158773/158773 [==============================] - 85s - loss: 1.5204      
Generating from seed:  so she we
 so she went on the dormouse she said to her had not the more to her had not the more to her had not the more
==================================================
Iteration #: 6
Epoch 1/1
158773/158773 [==============================] - 88s - loss: 1.4686      
Generating from seed:  and the d
 and the dormouse she was a little she was a little she was a little she was a little she was a little she was
==================================================
Iteration #: 7
Epoch 1/1
158773/158773 [==============================] - 92s - loss: 1.4250     
Generating from seed:  at the wi
 at the window, and the mock turtle said to herself in a long and said the caterpillar said the caterpillar sa
==================================================

So for example, after 7 rounds of training, the network would take the input " at the wi" and autocomplete it to the sequence, " at the window, and the mock turtle said to herself in a long and said the caterpillar said the caterpillar sa ".

Given that the network has only a single hidden recurrent layer and uses only sequences of 10 characters at a time for training, it's impressive the way it learns to mimic the type of whimsical sentence you might find in "Alice in Wonderland." Of course, for real use cases there would likely be many more hidden layers with more complicated network topologies, and there would be effort spent optimizing metaparameters like optimizer choices, learning rates, hidden layer sizes, and so forth. (Note also, that this is trained only on a CPU laptop, so the parameters are kept artificially constrained to facilitate faster training).

simplernn's People

Contributors

spearsem 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.