### Run a Single Example Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Execute a specific example script, such as the dense SIMD example. ```sh bun run examples/dense-simd.ts ``` -------------------------------- ### Install Dependencies Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Install project dependencies using Bun. ```sh bun install ``` -------------------------------- ### Run Specific Examples Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Execute individual example scripts to test specific functionalities. ```sh bun run examples/xor.ts bun run examples/sequence.ts bun run examples/wasm-graph.ts bun run examples/worker-population.ts bun run examples/neat-xor.ts bun run examples/lstm-sequence.ts bun run examples/gru-sequence.ts bun run examples/recurrent-training.ts bun run examples/dense-simd.ts bun run examples/per-step-sequence.ts ``` -------------------------------- ### Install Bunaptic with Bun Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Install the Bunaptic package using the Bun package manager. ```sh bun add bunaptic ``` -------------------------------- ### Bunaptic Setup for Fast Paths Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md This snippet shows the recommended Bunaptic setup for achieving fast inference paths. It involves loading the WASM kernel, packing the dataset, and initializing the network using the WASM kernel. ```typescript import { Network, loadWasmKernel, packDataset } from "bunaptic"; const kernel = await loadWasmKernel({ simd: "auto" }); const packed = packDataset(trainingSet, inputSize, outputSize); const fast = Network.fromJSON(model.toJSON()).useWasm(kernel); ``` -------------------------------- ### Install Bunaptic with npm Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Install the Bunaptic package using npm. This is for npm consumers after publication. ```sh npm install bunaptic ``` -------------------------------- ### Install Rust WASM Target Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Install the WASM target for Rust if it is missing. ```sh rustup target add wasm32-unknown-unknown ``` -------------------------------- ### Load WASM Kernel from Custom Path Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Loads the WebAssembly kernel from a specified URL path. Useful for custom build setups or non-standard module resolution. ```typescript const kernel = await loadWasmKernel({ path: new URL("./bunaptic_kernel.wasm", import.meta.url) }); ``` -------------------------------- ### Get and Set Network Parameters Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Retrieve the current parameters of a Bunaptic model and set them. This can be used for fine-tuning or transferring parameters. ```typescript const params = bunapticModel.getParameters(); bunapticModel.setParameters(params); ``` -------------------------------- ### Ragged Batch Inference with WASM Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Perform inference on ragged batches using WASM, avoiding padding by specifying sequence offsets. Offsets indicate value start positions. ```typescript const outputs = fast.runBatchRagged({ values: new Float32Array([ 1, 2, 3, 4, 5, 6, ]), offsets: new Uint32Array([0, 2, 6]), featureSize: 2, }); ``` -------------------------------- ### Run Benchmarks with Profiles Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Execute the main benchmark script with different profile settings. ```sh BENCH_PROFILE=ci bun run bench BENCH_PROFILE=quick bun run bench BENCH_PROFILE=standard bun run bench BENCH_PROFILE=large bun run bench ``` -------------------------------- ### Run Tests Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Execute the project's test suite. ```sh bun test ``` -------------------------------- ### Run Compact Release Check Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Execute a compact release check script. ```sh bun run check ``` -------------------------------- ### Import Core Bunaptic APIs Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Import the main Architect, Network, Neat, evaluatePopulation, and loadWasmKernel from the Bunaptic package. ```typescript import { Architect, Network, Neat, evaluatePopulation, loadWasmKernel } from "bunaptic"; ``` -------------------------------- ### NEAT Evolution with Dataset Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Initialize and evolve a NEAT network using a pre-packed dataset for evaluation. Supports custom seeds, population sizes, and elitism. ```typescript import { Neat, packDataset } from "bunaptic"; const neat = new Neat(2, 1, () => 0, { seed: 42, popsize: 64, elitism: 4, dataset: packDataset(trainingSet, 2, 1), evaluator: { mode: "auto", useWasm: true, }, }); for (let generation = 0; generation < 25; generation++) { const best = await neat.evolve(); console.log(generation, best.score); } ``` -------------------------------- ### Run Parent Repository Comparison Benchmark Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Execute a benchmark script located outside the current package to compare Neataptic/Bunaptic scenarios. ```sh BENCH_PROFILE=ci bun run tests/neataptic-speed-benchmark.ts ``` -------------------------------- ### Build Project Artifacts Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Build JavaScript declarations and scalar/SIMD WASM artifacts. ```sh bun run build ``` -------------------------------- ### Train and Test with Packed Datasets Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Illustrates using pre-packed datasets for training and testing, which can improve efficiency by preparing data buffers in advance. ```typescript const packed = packDataset(trainingSet, network.input, network.output); network.train(packed, { iterations: 500, rate: 0.3 }); network.testPacked(packed); ``` -------------------------------- ### Manual Dense Plan Usage Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Demonstrates manual usage of a dense neural network plan, including forward pass and dataset evaluation. Requires importing Architect and related functions. ```typescript import { Architect, denseEvaluateDataset, denseForward, deriveDensePlan, packDataset } from "bunaptic"; const model = Architect.Perceptron(2, 8, 4, 1); const plan = deriveDensePlan(model.compiledGraph()); if (plan) { const output = denseForward(plan, new Float32Array([0.25, 0.75])); const error = denseEvaluateDataset(plan, packDataset(trainingSet, 2, 1)); console.log(output, error); } ``` -------------------------------- ### Run Benchmark Scripts Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Execute the main benchmark script or the recurrent benchmark script. ```sh bun run bench bun run bench:recurrent ``` -------------------------------- ### Create and Activate a Perceptron Network Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Demonstrates the creation of a feed-forward Perceptron network with specified layers and performing an activation with sample input. ```typescript const network = Architect.Perceptron(3, 12, 4, 2); const output = network.activate([0.1, 0.5, 0.9]); ``` -------------------------------- ### Sequence Training Sample (Per-Step Output) Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Defines a sequence training sample where the output is provided for each step of the sequence. ```typescript const samples = [ { input: [0, 1, 1, 2, 2, 3], length: 3, output: [0, 1, 1], }, ]; ``` -------------------------------- ### Create Recurrent-Style Graph Builders Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Demonstrates the creation of different recurrent network architectures including basic RNN, NARX, and Hopfield networks. ```typescript const rnn = Architect.RNN(2, 8, 1); const narx = Architect.NARX(2, 1, 8, 2, 2); const hopfield = Architect.Hopfield(6); ``` -------------------------------- ### Train and Test a Network Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Shows how to train a network using a training set with various parameters and then evaluate its performance on a test set. ```typescript const result = network.train(trainingSet, { iterations: 500, error: 0.01, rate: 0.3, optimizer: "momentum", momentum: 0.1, shuffle: true, }); const score = network.test(testSet); ``` -------------------------------- ### Copy Network Parameters Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Shows how to extract network parameters and apply them to a newly created network, effectively cloning its learned state. ```typescript const params = network.getParameters(); const clone = Network.fromJSON(network.toJSON()).setParameters(params); ``` -------------------------------- ### Load WASM Kernel (Default) Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Loads the default Bunaptic WebAssembly kernel. This typically enables SIMD if the runtime supports it. ```typescript const kernel = await loadWasmKernel(); ``` -------------------------------- ### Use WASM Kernel for Network Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Loads and utilizes the WASM kernel for potentially faster network operations. Shows how to attach the kernel and perform an activation. ```typescript import { Architect, Network, loadWasmKernel } from "bunaptic"; const kernel = await loadWasmKernel({ simd: "auto" }); const model = Architect.Perceptron(2, 8, 1); const fast = Network.fromJSON(model.toJSON()).useWasm(kernel); console.log(kernel.simdEnabled); console.log(Array.from(fast.activate([0.2, 0.8]))); ``` -------------------------------- ### Import Bunaptic Core APIs Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Imports common high-level APIs from the Bunaptic library, useful for general network construction and manipulation. ```typescript import { Architect, GraphBuilder, MutationMethod, Neat, Network, Rng, WorkerPool, cost, denseEvaluateDataset, denseForward, deriveDensePlan, evaluatePopulation, loadWasmKernel, packDataset, packDensePlan, packSequenceDataset, trainDensePlan, } from "bunaptic"; ``` -------------------------------- ### loadWasmKernel Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Loads the Rust WASM kernel for accelerated computation. Supports SIMD acceleration. ```APIDOC ## loadWasmKernel ### Description Loads the Rust WASM kernel for accelerated computation. Supports SIMD acceleration. ### Signature `loadWasmKernel(options?: { simd: 'auto' | boolean }): Promise` ### Parameters * **options** (object) - Optional configuration. * **simd** ('auto' | boolean) - Enable or auto-detect SIMD support. ### Returns * (Promise) - A promise that resolves to the loaded WASM kernel instance. ``` -------------------------------- ### Machine-Readable Benchmark Output Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Generate benchmark results in JSON or CSV format for recurrent benchmarks. ```sh BENCH_PROFILE=ci BENCH_FORMAT=json bun run bench BENCH_PROFILE=ci BENCH_FORMAT=csv bun run bench:recurrent ``` -------------------------------- ### Neat Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Provides functionality for evolutionary algorithms, such as NeuroEvolution of Augmenting Topologies (NEAT). ```APIDOC ## Neat ### Description Provides functionality for evolutionary algorithms, such as NeuroEvolution of Augmenting Topologies (NEAT). ### Usage Instantiate `Neat` with a dataset or custom objective function to evolve networks. ``` -------------------------------- ### Import Runtime Target Markers Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Import runtime target markers to explicitly check the runtime environment. This is useful for conditional logic or specific runtime configurations. ```typescript import { runtimeTarget as bunTarget } from "bunaptic/bun"; import { runtimeTarget as nodeTarget } from "bunaptic/node"; console.log(bunTarget, nodeTarget); ``` -------------------------------- ### Create a Feed-Forward Perceptron Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Instantiates a multi-layer perceptron (MLP) with a specified number of input, hidden, and output neurons. ```typescript const mlp = Architect.Perceptron(2, 8, 4, 1); ``` -------------------------------- ### Import Neataptic JSON Model Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Import a feed-forward Neataptic JSON model into Bunaptic. This is useful for migrating existing Neataptic models. ```typescript const bunapticModel = Network.fromNeatapticJSON(neatapticModel.toJSON()); ``` -------------------------------- ### Network.createState Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Creates a state object for stateful graph sequence stepping. ```APIDOC ## Network.createState ### Description Creates a state object for stateful graph sequence stepping. ### Signature `network.createState(): any` ### Returns * (any) - An object representing the network's state. ``` -------------------------------- ### Train XOR Network Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Trains a simple Perceptron network to solve the XOR problem using a predefined dataset. Demonstrates basic network training and activation. ```typescript import { Architect } from "bunaptic"; const set = [ { input: [0, 0], output: [0] }, { input: [0, 1], output: [1] }, { input: [1, 0], output: [1] }, { input: [1, 1], output: [0] }, ]; const network = Architect.Perceptron(2, 6, 1); const result = network.train(set, { iterations: 1000, rate: 0.5, momentum: 0.1, shuffle: true, }); console.log(result); for (const sample of set) { console.log(sample.input, Array.from(network.activate(sample.input))); } ``` -------------------------------- ### Attach and Detach WASM Acceleration Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Demonstrates how to enable WASM acceleration for a network and then disable it, allowing for performance comparisons or specific use cases. ```typescript const kernel = await loadWasmKernel(); network.useWasm(kernel); network.activate([0.2, 0.8]); network.useWasm(null); ``` -------------------------------- ### Sequence Training Sample (Final Output) Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Defines a sequence training sample where the output corresponds to the final state of the sequence. ```typescript const samples = [ { input: [0, 1, 1, 2, 2, 3], length: 3, output: [1], }, ]; ``` -------------------------------- ### WASM Dense Plan Operations Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Demonstrates various dense plan operations executed via the WASM kernel, including single forward, batch forward, and dataset evaluation. ```typescript const kernel = await loadWasmKernel({ simd: "auto" }); const plan = deriveDensePlan(model.compiledGraph()); if (plan) { kernel.denseForwardPlan(plan, new Float32Array([0.25, 0.75])); kernel.denseForwardBatchPlan(plan, packed.inputs); kernel.denseEvaluatePackedDataset(plan, packed); } ``` -------------------------------- ### Network.fromJSON Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Creates a new network instance from a JSON object. ```APIDOC ## Network.fromJSON ### Description Creates a new network instance from a JSON object. ### Signature `Network.fromJSON(json: object): Network` ### Parameters * **json** (object) - The JSON object representing the network. ### Returns * (Network) - A new network instance created from the JSON. ``` -------------------------------- ### Create a Random Graph Network Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Generates a network with a random topology, allowing for customization of hidden layers, connections, and recurrence, with an optional seed for reproducibility. ```typescript const random = Architect.Random(4, 2, { hidden: 10, connections: 24, recurrent: 2, seed: 42, }); ``` -------------------------------- ### TypeScript BPTT Sequence Training Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Train a model using Backpropagation Through Time (BPTT) with TypeScript. Supports Adam optimizer with clipping and truncated steps. ```typescript model.trainSequences(packed, { optimizer: "adam", iterations: 100, rate: 0.05, clip: 1, truncatedSteps: 16, }); ``` -------------------------------- ### Load WASM Kernel with SIMD Auto Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Loads the WebAssembly kernel, automatically detecting and enabling SIMD support if available. This is the default behavior for optimized performance. ```typescript const kernel = await loadWasmKernel({ simd: "auto" }); ``` -------------------------------- ### Pack Sequence Dataset Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Pack sequence samples into a dataset format suitable for training. Supports 'auto' target mode inference. ```typescript const packed = packSequenceDataset(samples, 2, 1, { targetMode: "auto", }); ``` -------------------------------- ### Load WASM Kernel (Require SIMD) Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Loads the WebAssembly kernel, requiring SIMD support. The operation will fail if the runtime does not support SIMD. ```typescript const simd = await loadWasmKernel({ simd: true }); ``` -------------------------------- ### JSON Serialization Roundtrip Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Serialize a network to JSON and restore it from the JSON representation. ```typescript const json = network.toJSON(); const restored = Network.fromJSON(json); ``` -------------------------------- ### packSequenceDataset Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Packs sequential data into a contiguous buffer for recurrent network training. ```APIDOC ## packSequenceDataset ### Description Packs sequential data into a contiguous buffer for recurrent network training. ### Signature `packSequenceDataset(dataset: any, inputSize: number, outputSize: number): Float32Array` ### Parameters * **dataset** (any) - The sequential dataset to pack. * **inputSize** (number) - The size of each input step. * **outputSize** (number) - The size of each output step. ### Returns * (Float32Array) - A packed buffer containing the sequential dataset. ``` -------------------------------- ### Stateful Graph Sequence Stepping Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Manages and steps through a network's state for sequential processing, including creating, updating, and clearing the state. ```typescript const state = network.createState(); const first = network.step([0.1, 0.2], state); const second = network.step([0.3, 0.4], state); network.clearState(state); ``` -------------------------------- ### Architect.Random Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Creates a random graph network with specified properties. ```APIDOC ## Architect.Random ### Description Creates a random graph network with specified properties. ### Signature `Architect.Random(inputSize: number, outputSize: number, options?: { hidden?: number, connections?: number, recurrent?: number, seed?: number })` ### Parameters * **inputSize** (number) - The number of input nodes. * **outputSize** (number) - The number of output nodes. * **options** (object) - Optional configuration for the random graph. * **hidden** (number) - Number of hidden nodes. * **connections** (number) - Number of connections. * **recurrent** (number) - Number of recurrent connections. * **seed** (number) - Seed for random number generation. ``` -------------------------------- ### Binary Serialization Roundtrip Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Serialize a network to a binary format and restore it from the binary representation. The current encoder writes V2 binary payloads, preserving V1 compatibility. ```typescript const bytes = network.toBinary(); const restored = Network.fromBinary(bytes); ``` -------------------------------- ### Architect.RNN Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Creates a basic Recurrent Neural Network (RNN) graph builder. ```APIDOC ## Architect.RNN ### Description Creates a basic Recurrent Neural Network (RNN) graph builder. ### Signature `Architect.RNN(inputSize: number, hiddenSize: number, outputSize: number)` ### Parameters * **inputSize** (number) - The number of input nodes. * **hiddenSize** (number) - The number of hidden nodes. * **outputSize** (number) - The number of output nodes. ``` -------------------------------- ### Load WASM Kernel (Force Scalar) Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Loads the WebAssembly kernel, explicitly disabling SIMD support. Use this if SIMD causes issues or is not desired. ```typescript const scalar = await loadWasmKernel({ simd: false }); ``` -------------------------------- ### Create Fused LSTM/GRU Specs Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Instantiates Long Short-Term Memory (LSTM) and Gated Recurrent Unit (GRU) networks with fused recurrent capabilities, suitable for sequence modeling. ```typescript const lstm = Architect.LSTM(8, 32, 4, { seed: 42 }); const gru = Architect.GRU(8, 32, 4, { seed: 42 }); ``` -------------------------------- ### WASM Recurrent Path Sequence Training Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Train a model using WASM for recurrent path optimization. Supports Momentum optimizer with clipping. ```typescript const kernel = await loadWasmKernel(); const fast = Network.fromJSON(model.toJSON()).useWasm(kernel); fast.trainSequences(packed, { optimizer: "momentum", iterations: 100, rate: 0.02, momentum: 0.1, clip: 1, }); ``` -------------------------------- ### Network.getParameters Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Retrieves the current parameters (weights and biases) of the network. ```APIDOC ## Network.getParameters ### Description Retrieves the current parameters (weights and biases) of the network. ### Signature `network.getParameters(): number[]` ### Returns * (number[]) - An array representing the network's parameters. ``` -------------------------------- ### Pack and Inspect Dataset Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Converts a plain dataset into a packed format for efficiency and logs its properties. Packed datasets are optimized for transfer and caching. ```typescript const packed = packDataset(set, 2, 1); console.log(packed.inputSize); console.log(packed.outputSize); console.log(packed.sampleCount); console.log(packed.inputs instanceof Float32Array); console.log(packed.targets instanceof Float32Array); ``` -------------------------------- ### Network.step Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Performs a single step of sequence inference using the provided state. ```APIDOC ## Network.step ### Description Performs a single step of sequence inference using the provided state. ### Signature `network.step(input: number[], state: any): number[]` ### Parameters * **input** (number[]) - The input vector for the current step. * **state** (any) - The current state object. ### Returns * (number[]) - The output vector for the current step. ``` -------------------------------- ### Create Fused GRU Network Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Instantiate a fused Gated Recurrent Unit (GRU) network with specified input, hidden, and output sizes, and an optional seed. ```typescript const model = Architect.GRU(8, 32, 4, { seed: 42 }); const outputSteps = model.runSequence(new Float32Array(8 * 10)); ``` -------------------------------- ### Network.setParameters Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Sets the network's parameters from a given array. ```APIDOC ## Network.setParameters ### Description Sets the network's parameters from a given array. ### Signature `network.setParameters(params: number[]): Network` ### Parameters * **params** (number[]) - An array of parameters to set. ### Returns * (Network) - The network instance with updated parameters. ``` -------------------------------- ### packDataset Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Packs a dataset into a contiguous Float32Array buffer for efficient processing. ```APIDOC ## packDataset ### Description Packs a dataset into a contiguous Float32Array buffer for efficient processing. ### Signature `packDataset(dataset: any, inputSize: number, outputSize: number): Float32Array` ### Parameters * **dataset** (any) - The dataset to pack. * **inputSize** (number) - The size of each input sample. * **outputSize** (number) - The size of each output sample. ### Returns * (Float32Array) - A packed buffer containing the dataset. ``` -------------------------------- ### Network.train Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Trains a feed-forward network using a dataset. Supports various training configurations. ```APIDOC ## Network.train ### Description Trains a feed-forward network using a dataset. Supports various training configurations. ### Signature `network.train(dataset: any, options?: TrainingOptions)` ### Parameters * **dataset** (any) - The training dataset. Can be a standard array or a packed dataset. * **options** (object) - Optional training configuration. * **iterations** (number) - Maximum number of training iterations. * **error** (number) - Target error threshold. * **rate** (number) - Learning rate. * **optimizer** (string) - Optimization method (e.g., 'momentum'). * **momentum** (number) - Momentum factor if optimizer is 'momentum'. * **shuffle** (boolean) - Whether to shuffle the dataset before each epoch. ``` -------------------------------- ### Typecheck Project Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Perform TypeScript type checking without emitting JavaScript files. ```sh bunx tsc --noEmit ``` -------------------------------- ### Architect.Perceptron Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Creates a feed-forward Perceptron network. It takes the input size, output size, and a variable number of hidden layer sizes as arguments. ```APIDOC ## Architect.Perceptron ### Description Creates a feed-forward Perceptron network. ### Signature `Architect.Perceptron(inputSize: number, outputSize: number, ...hiddenLayers: number[])` ### Parameters * **inputSize** (number) - The number of input nodes. * **outputSize** (number) - The number of output nodes. * **...hiddenLayers** (number) - Variable number of hidden layer sizes. ``` -------------------------------- ### Network.test Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Evaluates the network's performance on a test dataset. ```APIDOC ## Network.test ### Description Evaluates the network's performance on a test dataset. ### Signature `network.test(testSet: any): number` ### Parameters * **testSet** (any) - The dataset to test the network on. ### Returns * (number) - The calculated score or error on the test set. ``` -------------------------------- ### Smoke Test Built Artifacts Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Perform smoke tests on the built artifacts to verify their integrity. ```sh bun run smoke ``` -------------------------------- ### Network.toJSON Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Serializes the network's architecture and parameters into a JSON object. ```APIDOC ## Network.toJSON ### Description Serializes the network's architecture and parameters into a JSON object. ### Signature `network.toJSON(): object` ### Returns * (object) - A JSON representation of the network. ``` -------------------------------- ### Architect.Hopfield Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Creates a Hopfield network graph builder. ```APIDOC ## Architect.Hopfield ### Description Creates a Hopfield network graph builder. ### Signature `Architect.Hopfield(size: number)` ### Parameters * **size** (number) - The number of nodes in the Hopfield network. ``` -------------------------------- ### Network.useWasm Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Attaches or detaches the WASM kernel for accelerated computation. ```APIDOC ## Network.useWasm ### Description Attaches or detaches the WASM kernel for accelerated computation. ### Signature `network.useWasm(kernel: WasmKernel | null): void` ### Parameters * **kernel** (WasmKernel | null) - The WASM kernel instance to use, or null to detach. ``` -------------------------------- ### Network.clearState Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Clears the state object for sequence stepping. ```APIDOC ## Network.clearState ### Description Clears the state object for sequence stepping. ### Signature `network.clearState(state: any): void` ### Parameters * **state** (any) - The state object to clear. ``` -------------------------------- ### evaluatePopulation Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Evaluates a population of networks, potentially using worker threads for parallel processing. ```APIDOC ## evaluatePopulation ### Description Evaluates a population of networks, potentially using worker threads for parallel processing. ### Signature `evaluatePopulation(population: any[], dataset: any, options?: { workers?: number }): Promise` ### Parameters * **population** (array) - An array of networks to evaluate. * **dataset** (any) - The dataset to use for evaluation. * **options** (object) - Optional configuration. * **workers** (number) - The number of worker threads to use for parallel evaluation. ### Returns * (Promise) - A promise that resolves to an array of evaluation results for each network in the population. ``` -------------------------------- ### Release Gate Validation Commands Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Commands used for release gate validation, including TypeScript type checking, running tests, building, and running benchmarks. ```sh bunx tsc --noEmit bun test bun run build bun run smoke BENCH_PROFILE=ci bun run bench BENCH_PROFILE=ci bun run bench:recurrent ``` -------------------------------- ### NEAT Evolution with Custom Objective Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Define a custom objective function for NEAT evolution by providing an async evaluator that calculates network error. ```typescript const neat = new Neat(2, 1, async (network) => { const result = network.test(trainingSet); return -result.error; }); ``` -------------------------------- ### Check SIMD Capability Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Checks if the loaded WASM kernel has SIMD capabilities enabled at runtime. This property reflects the actual runtime support. ```typescript console.log(kernel.simdEnabled); ``` -------------------------------- ### Create Fused LSTM Network Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Instantiate a fused Long Short-Term Memory (LSTM) network with specified input, hidden, and output sizes, and an optional seed. ```typescript const model = Architect.LSTM(8, 32, 4, { seed: 42 }); const outputSteps = model.runSequence(new Float32Array(8 * 10)); ``` -------------------------------- ### Network.trainSequences Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Trains a recurrent network on sequential data. ```APIDOC ## Network.trainSequences ### Description Trains a recurrent network on sequential data. ### Signature `network.trainSequences(trainingSet: any, options?: TrainingOptions)` ### Parameters * **trainingSet** (any) - The sequential training data. * **options** (object) - Optional training configuration (similar to `Network.train`). ``` -------------------------------- ### Network.testSequences Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Tests a recurrent network on sequential data. ```APIDOC ## Network.testSequences ### Description Tests a recurrent network on sequential data. ### Signature `network.testSequences(testSet: any): number` ### Parameters * **testSet** (any) - The sequential test data. ### Returns * (number) - The calculated score or error on the test set. ``` -------------------------------- ### Manual Worker Pool Lifecycle Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Manually manage a WorkerPool for evaluating populations. Ensure to terminate the pool when done to free resources. ```typescript import { WorkerPool, packDataset } from "bunaptic"; const pool = new WorkerPool({ size: 4, useWasm: true }); const packed = packDataset(trainingSet, 2, 1); try { await pool.cacheDataset(packed); const scores = await pool.evaluate(population, packed); console.log(scores); } finally { pool.terminate(); } ``` -------------------------------- ### Recurrent Network Streaming Continuation Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Manage recurrent state across multiple `runSequence` calls for streaming data. Allows resetting the state when needed. ```typescript const state = fast.createRecurrentState(); fast.runSequence(chunkA, { recurrentState: state }); fast.runSequence(chunkB, { recurrentState: state }); fast.resetRecurrentState(state); ``` -------------------------------- ### Architect.GRU Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Creates a fused Gated Recurrent Unit (GRU) network. Optimized for sequence modeling. ```APIDOC ## Architect.GRU ### Description Creates a fused Gated Recurrent Unit (GRU) network. Optimized for sequence modeling. ### Signature `Architect.GRU(inputSize: number, hiddenSize: number, outputSize: number, options?: { seed?: number })` ### Parameters * **inputSize** (number) - The number of input nodes. * **hiddenSize** (number) - The number of hidden nodes. * **outputSize** (number) - The number of output nodes. * **options** (object) - Optional configuration object. * **seed** (number) - Seed for random number generation. ``` -------------------------------- ### Evaluate Population with Workers Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Use evaluatePopulation for ordered fitness scores without manual cache or worker lifecycle management. Supports 'auto' mode for dynamic worker allocation. ```typescript import { Architect, evaluatePopulation, packDataset } from "bunaptic"; const population = Array.from({ length: 128 }, (_, index) => Architect.Perceptron(2, 8 + (index % 4), 1), ); const packed = packDataset(trainingSet, 2, 1); const scores = await evaluatePopulation(population, packed, { mode: "auto", workers: 4, useWasm: true, }); ``` -------------------------------- ### Recurrent Network Inference with WASM Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Utilize a loaded WASM kernel for fast recurrent network inference. Convert a JSON model to a WASM-enabled network. ```typescript const kernel = await loadWasmKernel(); const fast = Network.fromJSON(model.toJSON()).useWasm(kernel); const outputs = fast.runSequence(values); ``` -------------------------------- ### Network.mutate Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Applies a mutation operation to the network's structure or parameters. ```APIDOC ## Network.mutate ### Description Applies a mutation operation to the network's structure or parameters. ### Signature `network.mutate(method: MutationMethod)` ### Parameters * **method** (MutationMethod) - The mutation method to apply (e.g., `MutationMethod.ModWeight`, `MutationMethod.AddNode`, `MutationMethod.AddConnection`). ``` -------------------------------- ### Architect.LSTM Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Creates a fused Long Short-Term Memory (LSTM) network. Suitable for sequence modeling tasks. ```APIDOC ## Architect.LSTM ### Description Creates a fused Long Short-Term Memory (LSTM) network. Suitable for sequence modeling tasks. ### Signature `Architect.LSTM(inputSize: number, hiddenSize: number, outputSize: number, options?: { seed?: number })` ### Parameters * **inputSize** (number) - The number of input nodes. * **hiddenSize** (number) - The number of hidden nodes. * **outputSize** (number) - The number of output nodes. * **options** (object) - Optional configuration object. * **seed** (number) - Seed for random number generation. ``` -------------------------------- ### Define Plain Dataset Shape Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Defines a dataset with individual input and output arrays for each sample. Suitable for simple or initial dataset representations. ```typescript const set = [ { input: [0, 0], output: [0] }, { input: [0, 1], output: [1] }, ]; ``` -------------------------------- ### Mutate Network Topology Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Applies various mutation methods to alter the network's structure, such as adding weights, nodes, or connections. ```typescript network.mutate(MutationMethod.ModWeight); network.mutate(MutationMethod.AddNode); network.mutate(MutationMethod.AddConnection); ``` -------------------------------- ### Architect.NARX Source: https://github.com/nixaut-codelabs/bunaptic/blob/main/README.md Creates a Nonlinear Autoregressive with Exogenous Inputs (NARX) network graph builder. ```APIDOC ## Architect.NARX ### Description Creates a Nonlinear Autoregressive with Exogenous Inputs (NARX) network graph builder. ### Signature `Architect.NARX(inputSize: number, outputSize: number, hiddenSize: number, delay: number)` ### Parameters * **inputSize** (number) - The size of the exogenous input. * **outputSize** (number) - The size of the output. * **hiddenSize** (number) - The number of hidden nodes. * **delay** (number) - The delay for the autoregressive component. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.