Skip to content

Repository files navigation

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 datalocaltrain_features= {{0, 0}, {0, 1}, {1, 0}, {1, 1}}
localtrain_labels= {{0}, {1}, {1}, {0}}

Set up your model

localn_input=#train_features[1]
localn_output=#train_labels[1]
localmodel=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

localepochs=1000localerror=model.fit(train_features, train_labels, epochs)

Make predictions using your newly trained model

for_, predictioninpairs(model.predict(train_features)) doprint(table.concat(prediction, ", "))
end

About

A lightweight, simple, and modular machine learning library written in pure Lua.

Resources

Stars

41 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages