API Reference Documentation
Top-Level Exports
- Core:
Matrix,Vector,Tensor - Models:
LinearRegression,LogisticRegression,NaiveBayes,DiscretePerceptron,PolynomialRegression,KNN,WeightedKNN,KMeans,LinearSVM,PolynomialKernelSVM,SigmoidKernelSVM - Neural:
NeuralNetwork,DenseLayer,SoftmaxCrossEntropy - API:
ModelInferenceEngine - Loss:
MSELoss,BCELoss,CrossEntropy,hinge - Math:
relu,sigmoid,softmax,transpose,reshape,standardize,sum,arange,zeros,ones,gather,scatter,slice,minmax,euclidean_distance
Core Memory Structures
Vector
1D optimized numeric array backed by low-level flat typed buffers.
new Vector(size)- Initialize clear buffer.set(index, value)/get(index)- Explicit buffer manipulation.sum()/avg()- Analytical scalar reducers.toArray()- Returns JavaScript array instance.print(label?)- Logs output buffer to console.static from(array)- Instantiates vector out of raw JavaScript arrays.static zeros(size)- Generates a zeroed initialization container.static random(size)- Fills randomized parameters inside structure.
Matrix
2D structured layout utilizing explicit row-major performance mapping layouts.
new Matrix(rows, columns)- Allocates 2D structure.set(r, c, value)/get(r, c)- Coordinates configuration index hooks.getRow(r)/setRow(r, Float64Array)- Direct contiguous byte slice updates.print(label?)- Visualizes internal grid layout.static zeros(rows, columns)- Allocates flat cleared matrix frame.static matrixMulVector(matrix, vector)- High performance standard dot engine multiplication.static outerProduct(vectorA, vectorB)- Builds a full 2D output layout.static add(matrixA, matrixB)- Native operational sum processor.
Tensor
Flexible N-dimensional numeric container.
new Tensor(data)- Wraps multidimensional raw array arrays.clone()- Deep copies execution graph links and variables.static zeros(size)- Instantiates bounded zero tensor space.
Models
- LinearRegression - Linear predictive model with forward and backward methods.
- LogisticRegression - Binary classifier with sigmoid activation.
- NaiveBayes - Probabilistic classification model.
- DiscretePerceptron - Simple binary classifier with step activation.
- PolynomialRegression - Polynomial feature regression model.
- KNN - K-nearest neighbors classification.
- WeightedKNN - Weighted KNN variant.
- KMeans - Unsupervised clustering algorithm.
- LinearSVM - Support Vector Machine with linear kernel.
- PolynomialKernelSVM - SVM with polynomial kernel.
- SigmoidKernelSVM - SVM with sigmoid kernel.
Neural Engine Pipeline
Supports flexible dense multi-layer topological allocations and optimization routines.
new NeuralNetwork(input, hidden, output, loss)- Constructs network parameters.forward(input)- Run the network to produce output.backward(target)- Compute gradients from loss.ActivationEnum- Activation strategies: Linear, ReLU, Sigmoid, Softmax.SoftmaxCrossEntropy- Fused softmax and cross-entropy loss.
Loss Functions
- MSELoss - Mean Squared Error for regression.
- BCELoss - Binary Cross Entropy for binary classification.
- CrossEntropy - Multi-class cross-entropy.
- hinge - Loss used in SVM training.
Math Utilities
relu(vector)/sigmoid(vector)/softmax(vector)- Array execution activations.transpose(matrix)/reshape(array, shape)- Layout dimensional shifting utilities.standardize(vector)/minmax(vector)- Feature scaling operations.sum(vector)/euclidean_distance(a, b)- Reduction tracking algorithms.arange(start, end)/zeros(size)/ones(size)- Linear sequence allocation pools.gather(array, indices)/scatter(indices, values, shape)/slice(array, start, end)- Graph data mutations.
Inference Engine
ModelInferenceEngine loads serialized model payloads and performs forward inference.
import { ModelInferenceEngine } from 'tensorforgejs';
const engine = new ModelInferenceEngine(modelPayload);
const output = engine.forward(inputVector);