Coder Social home page Coder Social logo

gan-go's Introduction

Generative adversarial networks

Recipe for simple GAN in Golang ecosystem via Gorgonia library

Generating f(x) = x^2 Generating f(x) = sin(x)

Table of Contents

About

This just a repository with simple example how to build GAN in Gorgonia

What is GAN?

Note: although there is code with some wrappings/aliasing and helping abstractions and functions in repository, this does not pretend to be high-level machine learning framework

Note #2: By the way... Code is ugly since I've decided to handle errors instead of using panic(...) calls. Panicing is considered to be in main functions of examples only

Current examples folder contains limited set of layer types:

  • Linear
  • Convolutional
  • Maxpool
  • AvgPool
  • Flatten
  • Reshape
  • Reshape
  • Dropout
  • Embedding
  • LSTM

Why

Just want to do that in Golang ecosystem.

Instruments

Code is written on Golang - https://golang.org/

Used machine learning library - Gorgonia

Plotting library - gonum

Usage

  • Get the repo

    git clone https://github.com/LdDl/gan-go.git
  • Navigate to examples folder

    cd gan-go
    cd cmd/examples
  • Pick one of examples. E.g. parabola:

    cd parabola
  • Run example

    go run main.go
    
  • Output

    After programm terminates there should be multiple files:

    1. Single image for reference function - reference_function.png
    2. Multiple images for generated data on N-th epoch - gen_reference_fun_%N-th epoch%.png
    3. Single image for generated data on last epoch - gen_reference_func_final.png

    Example for parabola:

    Actual reference function:

    Reference function

    Generated data on 0-th epoch:

    Generated data on 0-th epoch

    Generated data on 10-th epoch:

    Generated data on 10-th epoch

    Generated data on 60-th epoch:

    Generated data on 60-th epoch

    Generated data on 150-th epoch:

    Generated data on 150-th epoch

    Generated data on last epoch:

    Generated data on last epoch

ToDo

Current stage of TODO list for future releases:

  • Reduce duplicating of code for .Fwd() method of each neural network type (GAN/Discriminator/Generator)
  • Switch Layer from struct to interface or use other technique for building clean code
  • Add basic layers: Linear, Convolutional, Maxpool, Flatten
  • Deal with batch process
  • More loss function
    • Cross Entropy
    • Binary Cross Entropy
    • L1
    • Huber (PSEUDO)
  • Examples for text data generation WIP
  • Simple LSTM
    • Proper layer types for RNN WIP
    • Examples
  • RNN
  • GRU
  • Embedding

Code explanation

@TODO

Support and contributing

If you have troubles or questions please open an issue.

If you want to improve this library / fix some bugs and etc. you can make PR

gan-go's People

Contributors

lddl avatar

Watchers

 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.