GithubHelp home page GithubHelp logo

sivavimel / ai-poem-generator-rnn Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 3.25 MB

An enchanting Recurrent Neural Network (RNN) model designed to generate captivating poems. Trained on the eloquent prose of Robert Green's '48 Laws of Power,' this repository is your gateway to the world of AI-powered poetry

Jupyter Notebook 86.09% Python 13.91%

ai-poem-generator-rnn's Introduction

AI-Poem-Generator-RNN

An enchanting Recurrent Neural Network (RNN) model designed to generate captivating poems. Trained on the eloquent prose of Robert Green's '48 Laws of Power,' this repository is your gateway to the world of AI-powered poetry

lv_0_20230819130247.mp4

Ladies and gentlemen,

Today, I am thrilled to introduce you to a fascinating world of text generation using a Recurrent Neural Network, or RNN for short. In this demonstration, we'll explore how RNNs can generate text, delve into the training process, and witness the incredible creative potential of artificial intelligence.

Our primary objective is to generate text that appears coherent, meaningful, and even artistic. We'll accomplish this by training our RNN on a dataset of text, in this case, Robert Green's writing on the '48 Laws of Power.' It's important to note that our model operates on the character level, which means it doesn't understand words or their meanings. It's all about patterns and probabilities.

Now, let's take a closer look at the steps involved:

  1. Data Preparation: First, we examine the dataset to understand the characters and their uniqueness. Then, we preprocess the text by converting it into a numerical format. We use the tf.keras.layers.StringLookup layer to map characters to numeric IDs and vice versa.

  2. Training Data: To train our model, we need pairs of inputs and labels. At each time step, the input is a character, and the label is the next character in the sequence. We chunk the text into sequences, and each sequence becomes an input and label pair.

  3. Model Building: Our model consists of several key components:

    • tf.keras.layers.Embedding: This layer converts character IDs into vectors.
    • tf.keras.layers.GRU: A type of Recurrent Neural Network.
    • tf.keras.layers.Dense: The output layer, predicting the next character.
  4. Training: We use a custom training loop to train our model. The loop tracks gradients, calculates loss, and updates the model using an optimizer. We're not using 'teacher-forcing,' so our model learns to recover from its own mistakes.

  5. Text Generation: Once the model is trained, we can use it to generate text. We do this by repeatedly feeding a seed text into the model and predicting the next character. This process continues, and we accumulate characters to form longer sequences.

The results are often intriguing. The model can generate text with proper capitalization and paragraph breaks, resembling a Shakespearean style. However, with a limited number of training epochs, it may not always create coherent sentences.

There are many ways to enhance the results. You can increase the number of training epochs, experiment with different start strings, adjust parameters like temperature to control randomness, or even add more RNN layers for accuracy.

In the end, this technology opens the door to exciting possibilities in natural language generation, creative writing, and more. It's a testament to the power of machine learning.

I encourage you to explore further, experiment with different texts, and unleash your creativity with this remarkable tool. The possibilities are as vast as your imagination.

Thank you for joining us on this journey into the world of text generation with RNNs. Now, let's witness our model's poetic talents in action!

Screenshot 2023-08-18 224817

Screenshot 2023-08-18 234943

Snake animation

ai-poem-generator-rnn's People

Contributors

sivavimel avatar

Watchers

Kostas Georgiou 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.