/nanoai

✨ Minimal library for creating neural networks

Primary LanguageLuaMIT LicenseMIT

Logo

Nanoai

Minimal library for creating neural networks.
npm package →

GitHub Workflow Status NPM Version GitHub License

Nanoai is a fast, lightweight library for handling multi-layer perceptron (MLP) neural networks.

The addition of recurrent and convolutional layers is not planned at this time.

📦 Setup

TypeScript

npm install @rbxts/nanoai
yarn add @rbxts/nanoai
pnpm add @rbxts/nanoai

Wally

Add littensy/nanoai to your wally.toml file.

[dependencies]
Nanoai = "littensy/nanoai@VERSION"

📚 API Reference

create(shape, activation)

predict(network, input)

backpropagate(network, input, expected, learningRate)

evolution(options)

init[type](network, ...)

initialize(network, initializer)

clone(network)

🚀 Examples

XOR problem

const model = Nanoai.create([2, 3, 1], Activation.TanH);

Nanoai.init.normal(model);

for (const _ of $range(1, 500)) {
	Nanoai.backpropagate(model, [0, 1], [1], 0.3);
	Nanoai.backpropagate(model, [1, 0], [1], 0.3);
	Nanoai.backpropagate(model, [0, 0], [0], 0.3);
	Nanoai.backpropagate(model, [1, 1], [0], 0.3);
}

Nanoai.predict(model, [0, 1]); // ~1

Nanoai is released under the MIT License.

MIT License