Git Product home page Git Product logo

lstm-xor's Introduction

LSTM XOR model

Overview

This project is a small exercise to train a recurrent neural network to learn the XOR operator. This is inspired as a warm-up exercise from OpenAI that can be found here.

How to run

To train and validate the model, execute

python run.py

To regenerate the dataset, go inside the dataset folder and execute

python generate_dataset.py

Dataset

The dataset is generated using generate_dataset.py. Given a sequence length and sample count, it will generate a dataset and save it as a CSV file.

Model architecture

I used an LSTM to input a 2-bit sequence of binary strings. It contains 512 hidden units and with input size of 1.

Optimizer

The optimizer used is the Adam optimizer with a learning rate of 1e-2.

Results

After running for one epoch, it has reached a training set loss of 0.01842 with accuracy of 0.98872. Running a validation set after one epoch has resulted to a loss of 0.00000 with 1.00000 accuracy.

The LSTM learned the XOR function by looking at over 100000 samples for training and 10000 samples in the validation set for evaluation.

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.