luaml

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package luaml is the require()-able host module that exposes the ml neural- network engine (native/ml + native/ml/training) to LuaScript as `ml`. It lives in its own package — rather than alongside the engine — because it imports both ml and ml/training, and training already imports ml; putting the loader in package ml would create an import cycle.

Lua surface:

local ml = require("ml")

local net = ml.new({
  inputs     = 2,
  layout     = { 4, 1 },        -- hidden(4) -> output(1)
  activation = "tanh",          -- sigmoid | tanh | relu | linear
  mode       = "binary",        -- default | binary | multiclass | regression | multilabel
  bias       = true,
  -- optional: loss, weight = { kind = "normal", stddev = 0.5 }
})

net:train({
  data       = {{ input = {0,0}, response = {0} }, ... },
  iterations = 2000,
  solver     = { kind = "adam", lr = 0.05 },   -- or { kind = "sgd", lr=.1, momentum=.9 }
  verbosity  = 500,                            -- print every N epochs (0 = silent)
  -- optional: validation = {...}, batch = { size = 16, parallelism = 4 }
})

local out = net:predict({1, 0})   -- -> array of output values
local blob = net:marshal()        -- JSON string; ml.load(blob) restores it

Every network method is colon-called, so the receiver is args[0] and the first real argument is at 1-based position 2 (matching the rest of the native modules).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterMLPreload

func RegisterMLPreload(v *vm.VM)

RegisterMLPreload installs the loader under package.preload as "ml".

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL