Giter Club home page Giter Club logo

neural-network-julia's Introduction

Neural-Network-Julia

A neural network implementation in Julia

Features

  • Construct a neural network with any number of layers
  • Only binary classification (for now)
  • Support for training on GPU

Requirements

  • Julia 1.3
  • TimerOutputs
  • IJulia (for jupyter notebooks given in the Examples directory)

For GPU support, the following are required (make sure that their tests are passing):

  • CuArrays (tested with v1.7.3)
  • CUDAnative (tested with v2.10.2)
  • CUDAdrv (optional, tested with v6.0.0)

Usage

Check out the examples for complete end-to-end training and testing examples.

  1. As of now, this has not been made into a Julia package. So you will have to include the NeuralNetwork.jl file to use it (also, there will be some JIT overhead during the first use). Download the files in this repo and import the functions by using (make sure to use the complete relative or absolute instead of just "NeuralNetwork.jl"):

    include("NeuralNetwork.jl")
  2. Load your training and testing data in the form of Float32 arrays (the outputs Y can be Int also).

  3. Use the neural_network_dense function to train the Neural Network. See the help section for more info - ?neural_network_dense should provide the docs. Here is an example usage:

    parameters, activations = neural_network_dense(train_X, train_Y, [12288, 10, 1], 1000, 0.001)

    [12288, 10, 1] is the number of neurons in each layer, 1000 is the number of steps to train for and 0.001 is the learning rate.

  4. Get predictions and accuracy using the predict function. Again, check out the help page for more details - ?predict. Example usage:

    predicts, accuracy = predict(test_X, test_Y, parameters, activations)
  5. (Optional) To see the time taken for each step in the Neural Network, use

    print_timer(to)

GPU Training:

  • include("NeuralNetworkGPU.jl")

  • Import the necessary packages - using CuArrays, CUDAnative, CUDAdrv

  • Convert the training data to CuArrays:

    train_X = CuArray(train_X)
    train_Y = CuArray(train_Y)
  • Use the same neural_network_dense and predict functions

  • That's it! (All the optmization for GPU is internal, take a look at NeuralNetworkGPU.jl)

TODO

  • Multi-class classification
  • Custom GPU kernels for activation functions on GPU

Acknowledgements

neural-network-julia's People

Contributors

samyak2 avatar

Stargazers

 avatar  avatar

Watchers

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