Git Product home page Git Product logo

fonet's Introduction

fonet

Build Status cover.run go Go Report Card GoDoc

fonet is a deep neural network package for Go. It's mainly created because I wanted to learn about neural networks and create my own package. I'm planning to continue the development of the package and add more function to it, for example exporting/importing a model.

Install

It's the same as everywhere, you just have to run the

go get github.com/Fontinalis/fonet

Usage

I focused (and still focusing) on creating an easy to use package, but let me know if something is not clear.

Creating a network

As in the xor example, it's not so complicated to create a network. When you creating the network, you always have to define the layers.

n := fonet.NewNetwork([]int{2, 3, 1})
/*
2 nodes in the INPUT LAYER
3 nodes in the HIDDEN LAYER
1 node in the OUTPUT LAYER
*/

But my goal was also to create a package, which can create deep neural networks too, so here is another example for that.

n := fonet.NewNetwork([]int{6, 12, 8, 4})
/*
6 nodes in the INPUT LAYER
12 nodes in the HIDDEN LAYER (1)
8 nodes in the HIDDEN LAYER (2)
4 nodes in the OUTPUT LAYER
*/

Train the network

After creating the network, you have to train your network. To do that, you have to specify your training set, which should be like the next

var trainingData = [][][]float64{
    [][]float64{ // The actual training sample
        []float64{
            /*
            The INPUT data
            */
        },
        []float64{
            /*
            The OUTPUT data
            */
        },
    },
}

After giving the training data, you can set the epoch and the learning rate.

n.Train(trainingData, epoch, lrate, true)
// Train(trainingData [][][]float64, epochs int, lrate float64, debug bool)

Note: When 'debug' is true, it'll show when and which epoch is finished

Predict the output

After training your network, using the Predict(..) function you can calculate the output for the given input.

In the case of XOR, it looks like the next

input := []float64{
    1,
    1,
}
out := n.Predict(input)

fonet's People

Contributors

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