Skip to content

Latest commit

 

History

History
101 lines (73 loc) · 3.28 KB

quick_start.md

File metadata and controls

101 lines (73 loc) · 3.28 KB

Quick Start Guide

This document shows how you can install and start using Learn Kit in your projects.

Installation

Learn Kit is a fully standalone ML module for Godot Engine, requiring no external dependencies. You can use it either as a separate workspace for experiments or embed it directly into your own game/application.

Prerequisites

  • Godot Engine 4.x+ (requires Vulkan for compute shader support) (4.6 is recommended)
  • GPU with Vulkan‑compatible drivers
  • Optional: Familiarity with GDScript and GLSL for extending networks or runners

Quick Install

  1. Clone/Download the Repository
git clone https://github.com/mkh-user/learn-kit.git

Or download repository from GitHub (https://github.com/mkh-user/learn-kit) and extract it.

  1. Open in Godot
  • Launch Godot.
  • If you want to use Learn Kit as a separate workspace for experiments:
    • Click on Import.
    • Navigate to project folder and select project.godot file.
  • If you want to embed Learn Kit to an existing project:
    • Copy addons/ folder of Learn Kit repository in your project root.
    • Open your project in Godot.
    • Go to Project > Project Settings... > Plugins and enable LearnKit plugin.

!!! note

Currently you can use all Learn Kit functionality without enabling it.
  1. Verify GPU Compatibility
  • Ensure your GPU supports Vulkan and compute shaders.
  • Verify these settings in Project > Project Settings... > General:
    • rendering/rendering_device/driver: vulkan for all target platforms
    • rendering/renderer/rendering_method: forward_plus for main setting
  1. Usage

The framework is built for fast prototyping and easy integration. You can create networks, set up GPU runners, train models, and export/import them — all from GDScript with a very clean API.

Example: Creating a network

var network := LearnKit.nn.network(
    [4, 32, 16, 3], # Layers
    null, # Use default forward pass runner
    LearnKit.ActivationType.RELU, # Hidden activations
    LearnKit.ActivationType.SOFTMAX, # Output activation
    LearnKit.WeightInitialization.KAIMING # Weights init
)

Example: Training a Network

var trainer := LearnKit.nn.trainer(
    network, # Network
    null, # Use default backward pass runner
    LearnKit.LossFunction.CCE, # Loss: Categorical Cross Entropy
    1e-2, # LR
    0, # l2 regularization lambda
    300, # Num epochs
    16, # Batch size
    LearnKit.nn.schedular.cosine(1e-2, 300, 3e-4), # Schedular (start_lr, n_epochs, min_lr)
    LearnKit.nn.optimizer(true, 1.0) # Grad clip optimizer
)
var split := LearnKit.data.train_test_split(inputs, targets, 0.2)

var time := trainer.train(split.train_inputs, split.train_targets)
var train_acc := LearnKit.evaluate.evaluate_model_soft_max(network, split.train_inputs, split.train_targets) * 100.0
var test_acc := LearnKit.evaluate.evaluate_model_soft_max(network, split.test_inputs, split.test_targets) * 100.0

print("Elapsed %d ms" % time)
print("Train acc: %f" % train_acc)
print("Test acc: %f" % test_acc)

Example: Exporting a Model

LearnKit.serialize.export(network, "user://model.json")

Example: Importing a Saved Model

network = LearnKit.serialize.import("user://model.json")

# Use network for inference...