Giter Site home page Giter Site logo

learn's Introduction

Learn's api is something like a combination between Torch and Scikit Learn. The purpose of Learn is to provide a flexible and portable neural network implementation that only depends on Lua. Learn is not multithreaded and does not use hardware acceleration, if you are looking for a high performance library I would suggest looking at Torch instead.

Start using Learn

Learn can be installed as a submodule for your git project by using the command:

git submodule add https://github.com/Polkm/learn.git learn

After you have Learn installed you can use it in an existing Lua project.

require("learn/learn")

Set up your training data

-- XOR training data
local train_features = {{0, 0}, {0, 1}, {1, 0}, {1, 1}}
local train_labels = {{0}, {1}, {1}, {0}}

Set up your model

local n_input = #train_features[1]
local n_output = #train_labels[1]

local model = learn.model.nnet({modules = {
  learn.layer.linear({n_input = n_input, n_output = n_input * 3}),
  learn.transfer.sigmoid({}),
  learn.layer.linear({n_input = n_input * 3, n_output = n_output}),
  learn.transfer.sigmoid({}),
}})

By default nnet will use the MSE criterion, appropriate for regression tasks.

Train your model on your data

local epochs = 1000
local error = model.fit(train_features, train_labels, epochs)

Make predictions using your newly trained model

for _, prediction in pairs(model.predict(train_features)) do
  print(table.concat(prediction, ", "))
end

learn's People

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.